@nex125/seatmap-editor 0.1.0 → 0.1.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/dist/index.d.cts CHANGED
@@ -1,14 +1,16 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Venue, Viewport, SpatialIndex, CommandHistory, Vec2 } from '@nex125/seatmap-core';
2
+ import { Venue, Viewport, SpatialIndex, CommandHistory, Vec2, Section } from '@nex125/seatmap-core';
3
3
  import { SeatmapStore } from '@nex125/seatmap-react';
4
4
  import { CSSProperties } from 'react';
5
5
 
6
6
  interface SeatmapEditorProps {
7
7
  venue?: Venue;
8
8
  onChange?: (venue: Venue) => void;
9
+ onSave?: (venue: Venue, serializedVenue: string) => void;
10
+ fetchCategoryPrices?: (categoryIds: string[]) => Promise<Record<string, number>>;
9
11
  className?: string;
10
12
  }
11
- declare function SeatmapEditor({ venue, onChange, className }: SeatmapEditorProps): react_jsx_runtime.JSX.Element;
13
+ declare function SeatmapEditor({ venue, onChange, onSave, fetchCategoryPrices, className }: SeatmapEditorProps): react_jsx_runtime.JSX.Element;
12
14
 
13
15
  interface ToolPointerEvent {
14
16
  worldX: number;
@@ -51,6 +53,8 @@ declare class SelectTool extends BaseTool {
51
53
  private dragStartWorld;
52
54
  private hasDragged;
53
55
  private dragMode;
56
+ private sectionResizeEnabled;
57
+ private resizeTargetSectionId;
54
58
  selectionRect: {
55
59
  x: number;
56
60
  y: number;
@@ -58,26 +62,84 @@ declare class SelectTool extends BaseTool {
58
62
  height: number;
59
63
  } | null;
60
64
  constructor(spatialIndex: SpatialIndex, history: CommandHistory);
61
- onPointerDown(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
62
- onPointerMove(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
65
+ setSectionResizeEnabled(enabled: boolean): void;
66
+ onPointerDown(e: ToolPointerEvent, viewport: Viewport, store: SeatmapStore): void;
67
+ onPointerMove(e: ToolPointerEvent, viewport: Viewport, store: SeatmapStore): void;
63
68
  onPointerUp(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
69
+ private commitAddPointOnSide;
64
70
  private commitDrag;
65
71
  private reset;
66
72
  onDeactivate(): void;
73
+ getSectionDragPreview(venue: {
74
+ sections: Array<{
75
+ id: string;
76
+ position: Vec2;
77
+ rotation: number;
78
+ outline: Vec2[];
79
+ }>;
80
+ } | null): Vec2[] | null;
81
+ getSectionDragPreviews(venue: {
82
+ sections: Array<{
83
+ id: string;
84
+ position: Vec2;
85
+ rotation: number;
86
+ outline: Vec2[];
87
+ }>;
88
+ } | null): Vec2[][];
89
+ getSectionResizeHandlesPreview(venue: {
90
+ sections: Section[];
91
+ } | null, selectedSeatIds: Set<string>, selectedSectionId?: string | null): {
92
+ corners: Vec2[];
93
+ sideMidpoints: Vec2[];
94
+ mergeHint: {
95
+ position: Vec2;
96
+ message: string;
97
+ } | null;
98
+ } | null;
99
+ getSeatDragPreview(venue: {
100
+ sections: Array<{
101
+ id: string;
102
+ position: Vec2;
103
+ rotation: number;
104
+ }>;
105
+ } | null): Vec2[];
106
+ private constrainSeatGroupDelta;
107
+ private commitSeatMoveWithinSection;
108
+ private buildSeatTransferVenue;
109
+ private findSectionAtWorldPoint;
110
+ private rotateSectionLocalDeltaToWorld;
111
+ private rotateWorldDeltaToSectionLocal;
112
+ private mapOriginalSeatPositionsToSection;
113
+ private findNonOverlappingSeatX;
114
+ private snapSeatGroupDelta;
115
+ private getEditableSection;
116
+ private toLocal;
117
+ private toWorld;
118
+ private findCornerHandleIndex;
119
+ private findSideHandleIndex;
120
+ private findMergeTargetIndex;
121
+ private findMergeCandidates;
122
+ private removeOutlineIndices;
123
+ private areOutlinesEqual;
124
+ private pickNearestSeatHit;
67
125
  }
68
126
 
127
+ type SectionCreationMode = "rectangle" | "polygon";
69
128
  declare class AddSectionTool extends BaseTool {
70
129
  private history;
71
130
  private categoryId;
72
131
  readonly name = "add-section";
73
132
  readonly cursor = "crosshair";
133
+ mode: SectionCreationMode;
74
134
  points: Vec2[];
75
135
  onPointsChange?: (points: Vec2[], closeable: boolean) => void;
76
136
  constructor(history: CommandHistory, categoryId?: string);
77
137
  setCategoryId(id: string): void;
138
+ setMode(mode: SectionCreationMode): void;
78
139
  onPointerDown(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
79
140
  onPointerMove(e: ToolPointerEvent): void;
80
- private finishPolygon;
141
+ private finishSection;
142
+ private rectangleFromDiagonal;
81
143
  private notifyChange;
82
144
  onDeactivate(): void;
83
145
  }
@@ -88,9 +150,19 @@ declare class AddRowTool extends BaseTool {
88
150
  readonly name = "add-row";
89
151
  readonly cursor = "cell";
90
152
  seatsPerRow: number;
153
+ rowsCount: number;
91
154
  seatSpacing: number;
155
+ rowOrientationDeg: number;
156
+ getPlacementPreview(worldX: number, worldY: number, venue: Venue | null): {
157
+ worldX: number;
158
+ worldY: number;
159
+ worldAngleRad: number;
160
+ } | null;
92
161
  constructor(history: CommandHistory, spatialIndex: SpatialIndex);
93
162
  onPointerDown(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
163
+ private findTargetSection;
164
+ private getFacingOrientationRad;
165
+ private getRowAxisRad;
94
166
  }
95
167
 
96
168
  declare class AddSeatTool extends BaseTool {
@@ -134,6 +206,9 @@ declare class AddTableTool extends BaseTool {
134
206
  interface ToolbarProps {
135
207
  activeTool: string;
136
208
  onToolChange: (tool: string) => void;
209
+ gridEnabled: boolean;
210
+ isGridOptionsOpen: boolean;
211
+ onToggleGridOptions: () => void;
137
212
  canUndo: boolean;
138
213
  canRedo: boolean;
139
214
  onUndo: () => void;
@@ -141,38 +216,46 @@ interface ToolbarProps {
141
216
  onFitView: () => void;
142
217
  onSave: () => void;
143
218
  onLoad: () => void;
144
- seatsPerRow: number;
145
- onSeatsPerRowChange: (n: number) => void;
146
219
  style?: CSSProperties;
147
220
  }
148
- declare function Toolbar({ activeTool, onToolChange, canUndo, canRedo, onUndo, onRedo, onFitView, onSave, onLoad, seatsPerRow, onSeatsPerRowChange, style, }: ToolbarProps): react_jsx_runtime.JSX.Element;
221
+ declare function Toolbar({ activeTool, onToolChange, gridEnabled, isGridOptionsOpen, onToggleGridOptions, canUndo, canRedo, onUndo, onRedo, onFitView, onSave, onLoad, style, }: ToolbarProps): react_jsx_runtime.JSX.Element;
149
222
 
150
223
  interface PropertyPanelProps {
151
224
  venue: Venue | null;
152
225
  selectedSeatIds: Set<string>;
226
+ selectedSectionIds: Set<string>;
153
227
  history: CommandHistory;
154
228
  store: SeatmapStore;
155
229
  onUploadBackground?: () => void;
156
230
  onRemoveBackground?: () => void;
157
231
  onBackgroundOpacityChange?: (opacity: number) => void;
232
+ onBackgroundSizeChange?: (size: {
233
+ width?: number;
234
+ height?: number;
235
+ }) => void;
236
+ onBackgroundKeepAspectRatioChange?: (keepAspectRatio: boolean) => void;
158
237
  style?: CSSProperties;
159
238
  }
160
- declare function PropertyPanel({ venue, selectedSeatIds, history, store, onUploadBackground, onRemoveBackground, onBackgroundOpacityChange, style, }: PropertyPanelProps): react_jsx_runtime.JSX.Element;
239
+ declare function PropertyPanel({ venue, selectedSeatIds, selectedSectionIds, history, store, onUploadBackground, onRemoveBackground, onBackgroundOpacityChange, onBackgroundSizeChange, onBackgroundKeepAspectRatioChange, style, }: PropertyPanelProps): react_jsx_runtime.JSX.Element;
161
240
 
162
241
  interface CategoryManagerProps {
163
242
  venue: Venue | null;
164
243
  history: CommandHistory;
165
244
  store: SeatmapStore;
245
+ fetchCategoryPrices?: (categoryIds: string[]) => Promise<Record<string, number>>;
166
246
  style?: CSSProperties;
167
247
  }
168
- declare function CategoryManager({ venue, history, store, style, }: CategoryManagerProps): react_jsx_runtime.JSX.Element | null;
248
+ declare function CategoryManager({ venue, history, store, fetchCategoryPrices, style, }: CategoryManagerProps): react_jsx_runtime.JSX.Element | null;
169
249
 
170
250
  interface LayerPanelProps {
171
251
  venue: Venue | null;
172
252
  selectedSeatIds: Set<string>;
173
- onSelectSection: (sectionId: string) => void;
253
+ selectedSectionIds: Set<string>;
254
+ onSelectSection: (sectionId: string, options?: {
255
+ multi?: boolean;
256
+ }) => void;
174
257
  style?: CSSProperties;
175
258
  }
176
- declare function LayerPanel({ venue, selectedSeatIds, onSelectSection, style, }: LayerPanelProps): react_jsx_runtime.JSX.Element | null;
259
+ declare function LayerPanel({ venue, selectedSeatIds, selectedSectionIds: storeSelectedSectionIds, onSelectSection, style, }: LayerPanelProps): react_jsx_runtime.JSX.Element | null;
177
260
 
178
261
  export { AddRowTool, AddSeatTool, AddSectionTool, AddTableTool, BaseTool, CategoryManager, DrawGATool, LayerPanel, PanTool, PropertyPanel, SeatmapEditor, type SeatmapEditorProps, SelectTool, type ToolPointerEvent, Toolbar };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Venue, Viewport, SpatialIndex, CommandHistory, Vec2 } from '@nex125/seatmap-core';
2
+ import { Venue, Viewport, SpatialIndex, CommandHistory, Vec2, Section } from '@nex125/seatmap-core';
3
3
  import { SeatmapStore } from '@nex125/seatmap-react';
4
4
  import { CSSProperties } from 'react';
5
5
 
6
6
  interface SeatmapEditorProps {
7
7
  venue?: Venue;
8
8
  onChange?: (venue: Venue) => void;
9
+ onSave?: (venue: Venue, serializedVenue: string) => void;
10
+ fetchCategoryPrices?: (categoryIds: string[]) => Promise<Record<string, number>>;
9
11
  className?: string;
10
12
  }
11
- declare function SeatmapEditor({ venue, onChange, className }: SeatmapEditorProps): react_jsx_runtime.JSX.Element;
13
+ declare function SeatmapEditor({ venue, onChange, onSave, fetchCategoryPrices, className }: SeatmapEditorProps): react_jsx_runtime.JSX.Element;
12
14
 
13
15
  interface ToolPointerEvent {
14
16
  worldX: number;
@@ -51,6 +53,8 @@ declare class SelectTool extends BaseTool {
51
53
  private dragStartWorld;
52
54
  private hasDragged;
53
55
  private dragMode;
56
+ private sectionResizeEnabled;
57
+ private resizeTargetSectionId;
54
58
  selectionRect: {
55
59
  x: number;
56
60
  y: number;
@@ -58,26 +62,84 @@ declare class SelectTool extends BaseTool {
58
62
  height: number;
59
63
  } | null;
60
64
  constructor(spatialIndex: SpatialIndex, history: CommandHistory);
61
- onPointerDown(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
62
- onPointerMove(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
65
+ setSectionResizeEnabled(enabled: boolean): void;
66
+ onPointerDown(e: ToolPointerEvent, viewport: Viewport, store: SeatmapStore): void;
67
+ onPointerMove(e: ToolPointerEvent, viewport: Viewport, store: SeatmapStore): void;
63
68
  onPointerUp(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
69
+ private commitAddPointOnSide;
64
70
  private commitDrag;
65
71
  private reset;
66
72
  onDeactivate(): void;
73
+ getSectionDragPreview(venue: {
74
+ sections: Array<{
75
+ id: string;
76
+ position: Vec2;
77
+ rotation: number;
78
+ outline: Vec2[];
79
+ }>;
80
+ } | null): Vec2[] | null;
81
+ getSectionDragPreviews(venue: {
82
+ sections: Array<{
83
+ id: string;
84
+ position: Vec2;
85
+ rotation: number;
86
+ outline: Vec2[];
87
+ }>;
88
+ } | null): Vec2[][];
89
+ getSectionResizeHandlesPreview(venue: {
90
+ sections: Section[];
91
+ } | null, selectedSeatIds: Set<string>, selectedSectionId?: string | null): {
92
+ corners: Vec2[];
93
+ sideMidpoints: Vec2[];
94
+ mergeHint: {
95
+ position: Vec2;
96
+ message: string;
97
+ } | null;
98
+ } | null;
99
+ getSeatDragPreview(venue: {
100
+ sections: Array<{
101
+ id: string;
102
+ position: Vec2;
103
+ rotation: number;
104
+ }>;
105
+ } | null): Vec2[];
106
+ private constrainSeatGroupDelta;
107
+ private commitSeatMoveWithinSection;
108
+ private buildSeatTransferVenue;
109
+ private findSectionAtWorldPoint;
110
+ private rotateSectionLocalDeltaToWorld;
111
+ private rotateWorldDeltaToSectionLocal;
112
+ private mapOriginalSeatPositionsToSection;
113
+ private findNonOverlappingSeatX;
114
+ private snapSeatGroupDelta;
115
+ private getEditableSection;
116
+ private toLocal;
117
+ private toWorld;
118
+ private findCornerHandleIndex;
119
+ private findSideHandleIndex;
120
+ private findMergeTargetIndex;
121
+ private findMergeCandidates;
122
+ private removeOutlineIndices;
123
+ private areOutlinesEqual;
124
+ private pickNearestSeatHit;
67
125
  }
68
126
 
127
+ type SectionCreationMode = "rectangle" | "polygon";
69
128
  declare class AddSectionTool extends BaseTool {
70
129
  private history;
71
130
  private categoryId;
72
131
  readonly name = "add-section";
73
132
  readonly cursor = "crosshair";
133
+ mode: SectionCreationMode;
74
134
  points: Vec2[];
75
135
  onPointsChange?: (points: Vec2[], closeable: boolean) => void;
76
136
  constructor(history: CommandHistory, categoryId?: string);
77
137
  setCategoryId(id: string): void;
138
+ setMode(mode: SectionCreationMode): void;
78
139
  onPointerDown(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
79
140
  onPointerMove(e: ToolPointerEvent): void;
80
- private finishPolygon;
141
+ private finishSection;
142
+ private rectangleFromDiagonal;
81
143
  private notifyChange;
82
144
  onDeactivate(): void;
83
145
  }
@@ -88,9 +150,19 @@ declare class AddRowTool extends BaseTool {
88
150
  readonly name = "add-row";
89
151
  readonly cursor = "cell";
90
152
  seatsPerRow: number;
153
+ rowsCount: number;
91
154
  seatSpacing: number;
155
+ rowOrientationDeg: number;
156
+ getPlacementPreview(worldX: number, worldY: number, venue: Venue | null): {
157
+ worldX: number;
158
+ worldY: number;
159
+ worldAngleRad: number;
160
+ } | null;
92
161
  constructor(history: CommandHistory, spatialIndex: SpatialIndex);
93
162
  onPointerDown(e: ToolPointerEvent, _viewport: Viewport, store: SeatmapStore): void;
163
+ private findTargetSection;
164
+ private getFacingOrientationRad;
165
+ private getRowAxisRad;
94
166
  }
95
167
 
96
168
  declare class AddSeatTool extends BaseTool {
@@ -134,6 +206,9 @@ declare class AddTableTool extends BaseTool {
134
206
  interface ToolbarProps {
135
207
  activeTool: string;
136
208
  onToolChange: (tool: string) => void;
209
+ gridEnabled: boolean;
210
+ isGridOptionsOpen: boolean;
211
+ onToggleGridOptions: () => void;
137
212
  canUndo: boolean;
138
213
  canRedo: boolean;
139
214
  onUndo: () => void;
@@ -141,38 +216,46 @@ interface ToolbarProps {
141
216
  onFitView: () => void;
142
217
  onSave: () => void;
143
218
  onLoad: () => void;
144
- seatsPerRow: number;
145
- onSeatsPerRowChange: (n: number) => void;
146
219
  style?: CSSProperties;
147
220
  }
148
- declare function Toolbar({ activeTool, onToolChange, canUndo, canRedo, onUndo, onRedo, onFitView, onSave, onLoad, seatsPerRow, onSeatsPerRowChange, style, }: ToolbarProps): react_jsx_runtime.JSX.Element;
221
+ declare function Toolbar({ activeTool, onToolChange, gridEnabled, isGridOptionsOpen, onToggleGridOptions, canUndo, canRedo, onUndo, onRedo, onFitView, onSave, onLoad, style, }: ToolbarProps): react_jsx_runtime.JSX.Element;
149
222
 
150
223
  interface PropertyPanelProps {
151
224
  venue: Venue | null;
152
225
  selectedSeatIds: Set<string>;
226
+ selectedSectionIds: Set<string>;
153
227
  history: CommandHistory;
154
228
  store: SeatmapStore;
155
229
  onUploadBackground?: () => void;
156
230
  onRemoveBackground?: () => void;
157
231
  onBackgroundOpacityChange?: (opacity: number) => void;
232
+ onBackgroundSizeChange?: (size: {
233
+ width?: number;
234
+ height?: number;
235
+ }) => void;
236
+ onBackgroundKeepAspectRatioChange?: (keepAspectRatio: boolean) => void;
158
237
  style?: CSSProperties;
159
238
  }
160
- declare function PropertyPanel({ venue, selectedSeatIds, history, store, onUploadBackground, onRemoveBackground, onBackgroundOpacityChange, style, }: PropertyPanelProps): react_jsx_runtime.JSX.Element;
239
+ declare function PropertyPanel({ venue, selectedSeatIds, selectedSectionIds, history, store, onUploadBackground, onRemoveBackground, onBackgroundOpacityChange, onBackgroundSizeChange, onBackgroundKeepAspectRatioChange, style, }: PropertyPanelProps): react_jsx_runtime.JSX.Element;
161
240
 
162
241
  interface CategoryManagerProps {
163
242
  venue: Venue | null;
164
243
  history: CommandHistory;
165
244
  store: SeatmapStore;
245
+ fetchCategoryPrices?: (categoryIds: string[]) => Promise<Record<string, number>>;
166
246
  style?: CSSProperties;
167
247
  }
168
- declare function CategoryManager({ venue, history, store, style, }: CategoryManagerProps): react_jsx_runtime.JSX.Element | null;
248
+ declare function CategoryManager({ venue, history, store, fetchCategoryPrices, style, }: CategoryManagerProps): react_jsx_runtime.JSX.Element | null;
169
249
 
170
250
  interface LayerPanelProps {
171
251
  venue: Venue | null;
172
252
  selectedSeatIds: Set<string>;
173
- onSelectSection: (sectionId: string) => void;
253
+ selectedSectionIds: Set<string>;
254
+ onSelectSection: (sectionId: string, options?: {
255
+ multi?: boolean;
256
+ }) => void;
174
257
  style?: CSSProperties;
175
258
  }
176
- declare function LayerPanel({ venue, selectedSeatIds, onSelectSection, style, }: LayerPanelProps): react_jsx_runtime.JSX.Element | null;
259
+ declare function LayerPanel({ venue, selectedSeatIds, selectedSectionIds: storeSelectedSectionIds, onSelectSection, style, }: LayerPanelProps): react_jsx_runtime.JSX.Element | null;
177
260
 
178
261
  export { AddRowTool, AddSeatTool, AddSectionTool, AddTableTool, BaseTool, CategoryManager, DrawGATool, LayerPanel, PanTool, PropertyPanel, SeatmapEditor, type SeatmapEditorProps, SelectTool, type ToolPointerEvent, Toolbar };