@knot-technologies/seatmap 0.4.0-dev.1 → 0.4.0-dev.10

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
@@ -42,19 +42,28 @@ Call `await chart.destroy()` when the integration is removed. The chart handle i
42
42
 
43
43
  ## Methods
44
44
 
45
- The v0.1 chart handle implements these ten methods:
45
+ The chart handle implements these methods:
46
46
 
47
47
  - `selectObjects(objects)`
48
48
  - `deselectObjects(objects)`
49
49
  - `clearSelection()`
50
50
  - `listSelectedObjects()`
51
+ - `listFloors()`
52
+ - `goToFloor(floorId)`
53
+ - `goToAllFloors()`
51
54
  - `setObjectQuantity(object, quantity)`
52
55
  - `highlightObjects(objects, color?)`
53
56
  - `clearHighlights()`
54
57
  - `setMetadata(metadata)`
55
58
  - `setCategoryMetadata(metadata)`
59
+ - `changeConfig(config)`
60
+ - `zoomToSection(sectionId)`
61
+ - `zoomToObjects(objects)`
62
+ - `resetView()`
56
63
  - `destroy()`
57
64
 
65
+ `changeConfig({})` resolves without changing state or emitting events.
66
+
58
67
  ## Events
59
68
 
60
69
  Subscribe with `chart.on(event, handler)` and unsubscribe with `chart.off(event, handler)`:
@@ -67,6 +76,128 @@ Subscribe with `chart.on(event, handler)` and unsubscribe with `chart.off(event,
67
76
  - `selectionChanged`
68
77
  - `objectMouseOver`
69
78
  - `objectMouseOut`
79
+ - `seatBlocked`
80
+ - `objectStatusChanged`: fires after render for each seat whose status changes, with `status`, `previousStatus` and `selected`. It never deselects the seat.
81
+ - `zoomLevelChanged`
82
+ - `viewportChanged`
83
+ - `sectionFocused`
84
+ - `sectionUnfocused`
85
+ - `seasonHoldChanged`
86
+ - `floorChanged`
87
+
88
+ ## Floors
89
+
90
+ Classic and Season mounts accept `startFloor?: string`, `lockedFloor?: string` and
91
+ `showFloorPicker?: boolean`. The picker is shown by default. A locked floor takes
92
+ precedence over the start floor, hides the picker and prevents buyer switching.
93
+ An unknown start or locked floor logs a warning and is ignored. The widget opens
94
+ on the valid locked floor, otherwise the valid start floor, otherwise All floors
95
+ (including single-floor charts). If the overview is unavailable, it uses the first floor.
96
+ Hiding the picker with `showFloorPicker: false` still allows code navigation.
97
+ In React, pass these options in `KnotSeatmap`'s `config`.
98
+
99
+ `listFloors()` resolves to `{ id, name, shortName, categoryIds }[]`, lowest first,
100
+ or `[]` on a flat chart. `goToFloor(floorId)` resolves without a value; it rejects
101
+ with `NO_FLOORS` on a flat chart, `FLOOR_NOT_FOUND` for an unknown id, or
102
+ `FLOOR_LOCKED` when navigating away from the locked floor. Navigating to the locked
103
+ floor is allowed. `goToAllFloors()` rejects with `NO_FLOORS` on a flat chart,
104
+ then `FLOOR_LOCKED` for a valid lock, or `OVERVIEW_UNAVAILABLE` when
105
+ `overviewUnavailable` is true. Otherwise it resolves without a value; on multi-floor
106
+ charts it opens the projected overview, whose gestures adjust camera height.
107
+
108
+ `floorChanged` carries `{ floor: SeatmapFloor | null }` on the initial floor and
109
+ each floor change, including code navigation. The current floor is replayed to
110
+ new subscribers so the initial event is available after `mountSeatmap()` resolves.
111
+ `null` is reserved for the all-floors view. Flat charts emit no floor event.
112
+ Seat, GA area, table and section-focus payloads include `floorId?: string` only on
113
+ multi-floor charts. `SeatmapFloor` is exported by the types, vanilla and React
114
+ packages.
115
+
116
+ ## Section contents
117
+
118
+ Classic and season mounts, including React's `config`, accept `sectionContents`:
119
+
120
+ | Mode | Presentation |
121
+ | ------------------ | ------------------------------------------------------------------------------------------------------ |
122
+ | `always` (default) | Seats stay visible at every zoom; section colour fades as seats become discernible. |
123
+ | `seatsOnly` | Seats stay visible without a section-colour fill. Section names and interactions remain available. |
124
+ | `afterZoom` | Sections show their colour until opened or zoomed in; opening a section reveals its seats immediately. |
125
+
126
+ Change the mode with `await chart.changeConfig({ sectionContents: 'afterZoom' })`.
127
+ The same patch can include `categoryFilter`; the whole patch is validated before
128
+ anything changes. Omitted fields retain their current values. These modes change
129
+ presentation, while geometry and the input's clickable size determine selection.
130
+
131
+ ## Camera methods
132
+
133
+ `resetView()` does the same thing as Fit: clear section focus and return to the
134
+ active floor's start view, or the full chart on a flat chart. The start view fits
135
+ inside a 17 CSS px border and caps representative seats at their landing size.
136
+ Reset keeps the active floor, selection and holds. In All floors it restores the
137
+ existing overview camera height and refits the overview.
138
+
139
+ `zoomToSection(sectionId)` frames and focuses the block using the same framing
140
+ path as keyboard entry, independently of the current zoom. It uses the widget's latest pointer input,
141
+ with mouse as the default before any pointer event.
142
+
143
+ `zoomToObjects(objects)` validates every typed seat, GA area or table reference
144
+ before changing floor or focus. One seat is centred at a target landing size: 24 CSS px
145
+ for mouse/pen, 32 for touch, measured across the seat's shorter drawn dimension.
146
+ A group fits the union of its complete shapes without cropping, capped at its
147
+ representative landing size. Landing sizes are subject to the camera maximum and
148
+ complete-shape containment. Seat-booked tables use their chairs as the size reference;
149
+ whole/variable-booked tables use their bodies. GA polygons and complete table/chair
150
+ shapes are included.
151
+ Object navigation clears section focus. Camera methods never select or hold.
152
+
153
+ Both target methods switch to the target floor, including from All floors, and
154
+ wait for its transition before moving. Unknown IDs, empty lists and cross-floor
155
+ object sets reject with `RPC_INVALID_ARGS`; targets outside a valid locked floor
156
+ reject with `FLOOR_LOCKED`. An unavailable viewport or invalid target geometry
157
+ uses the existing camera failure envelope (`ENGINE_INCOMPATIBLE`), without a
158
+ partial move. A command rejected while hidden cannot execute later on reveal.
159
+
160
+ Wait for `chartRendered` before making the first camera call. `mountSeatmap`
161
+ resolves after initialization, while geometry may still be loading. The event
162
+ is replayed to late subscribers:
163
+
164
+ ```ts
165
+ await new Promise<void>(resolve => {
166
+ const onRendered = () => {
167
+ chart.off('chartRendered', onRendered);
168
+ resolve();
169
+ };
170
+ chart.on('chartRendered', onRendered);
171
+ });
172
+ await chart.zoomToSection('section-a');
173
+ ```
174
+
175
+ Promises resolve after the requested pose is applied. Moves use 700 ms cubic
176
+ ease-in/out; reduced motion applies the pose immediately. Supersession, direct
177
+ input, resize, floor/geometry replacement and camera unmount interrupt outstanding
178
+ moves with `CAMERA_INTERRUPTED`. Automatic initial and resize fits still wait for
179
+ a measurable stage. Resize refits the newest fitted content; manual inspection
180
+ preserves its world anchor and magnification within the camera limits.
181
+
182
+ The + control doubles magnification; − halves it toward the start view. Both use
183
+ 700 ms ease-out. Fit returns directly to the active floor's start view. Seat
184
+ clicks zoom toward seats that are too small to click, then select clickable seats
185
+ in place through the normal selection rules.
186
+
187
+ `zoomLevelChanged` preserves `{ level, scale, seatPixelSize }`: one event after
188
+ the initial settled fit, then an event when the semantic level changes. Start
189
+ views report `overview`, closer views below the input's clickable size report
190
+ `section`, and clickable reference seats report `seat`. Measurements follow the
191
+ active floor and local viewing anchor, independent of chart seat count.
192
+ `scale` is the camera scale; `seatPixelSize` is a representative summary, so it
193
+ does not guarantee that every object is clickable. Levels do not control labels,
194
+ visibility or hit testing.
195
+
196
+ `viewportChanged` retains the finite current transform and world bounds.
197
+ `sectionFocused`/`sectionUnfocused` follow block entry, replacement, Fit and floor
198
+ changes. Zoom, viewport and focus events are live subscriptions with no replay.
199
+ The existing replay of `chartRendered`, `floorChanged` and `seasonHoldChanged`
200
+ is unchanged.
70
201
 
71
202
  ## Deferred methods
72
203
 
@@ -78,8 +209,6 @@ The public contract reserves these method names for later releases:
78
209
  - `disableObjects` and `enableObjects`
79
210
  - `selectCategories`, `deselectCategories`, and `listCategories`
80
211
  - `findObject`
81
- - `zoomToObjects`, `zoomToSection`, and `resetView`
82
- - `changeConfig`
83
212
 
84
213
  Calling a deferred method rejects with a typed error whose code is `METHOD_NOT_IMPLEMENTED` and whose message names the method. Deferred methods never silently succeed.
85
214
 
@@ -113,3 +242,66 @@ export function Seatmap({ sessionId, clientToken }) {
113
242
  ```
114
243
 
115
244
  Do not call `mountSeatmap` during server rendering. The React package itself is safe to import during SSR; mounting starts from its client-side effect.
245
+
246
+ ### Server-confirmed fixed seats
247
+
248
+ Classic embeds can connect their reservation handler with `onSeatSelectionChange`:
249
+
250
+ ```ts
251
+ const chart = await mountSeatmap(container, {
252
+ sessionId,
253
+ clientToken,
254
+ onSeatSelectionChange: async ({ seatIds, selected }) => {
255
+ await reservationClient.updateSeats({ seatIds, selected });
256
+ },
257
+ });
258
+ ```
259
+
260
+ Resolve after the server confirms the hold or release; reject on failure.
261
+ The widget keeps a fine ring and loader while the promise is pending, then morphs
262
+ that loader into a tick on confirmation. Pending additions are absent from
263
+ selected-object counts and events. Pending removals retain their confirmed
264
+ selection. Rejection restores the prior appearance; a different request succeeding
265
+ does not clear the error. Repeated activation of a pending seat is ignored.
266
+ Different seats can update concurrently; resale seat groups are sent together.
267
+ The host owns server requests, idempotency and reconciliation.
268
+
269
+ `selectObjects`, `deselectObjects` and `clearSelection` wait for these callbacks.
270
+ Use the callback instead of also reserving from `objectSelected`, which reports
271
+ confirmation in this mode. React accepts the same callback in `config`. Without
272
+ it, classic selection stays local and immediate. This option covers fixed seats;
273
+ table and GA quantity handlers retain their existing contracts. Season embeds
274
+ use their existing hold controller and do not accept this callback. With reduced
275
+ motion, the pending arc is stationary and changes directly into the tick.
276
+
277
+ ### Label colour scheme
278
+
279
+ Both classic and Season mounts accept `colorScheme: 'light' | 'dark'`. Omit it for light labels. It affects automatic labels, while chart, decoration and category seat colours keep their stored appearance. Row letters and seat numbers are text with no backing: beside seats they use one colour per scheme, and inside a seat they use an ink that reads on its fill. Fully shown sold-out badge text stays readable while blocks remain dimmed. Zoom fades still apply.
280
+
281
+ In React, pass the option in `KnotSeatmap`'s `config`. Changing between light and dark remounts the chart, resetting its camera and selection like other mount options. Omitted and explicit light are equivalent for mount dependencies; ordinary rerenders, new config objects and callback identities preserve the existing chart. `changeConfig` does not accept a colour scheme. Publish the SDK with its matching immutable engine artifact.
282
+
283
+ ### Legend
284
+
285
+ Both classic and Season mounts accept a `legend` object:
286
+
287
+ ```ts
288
+ const chart = await mountSeatmap(container, {
289
+ sessionId,
290
+ clientToken,
291
+ legend: { content: 'name', hideAccessibleSeatsFilter: true },
292
+ });
293
+ ```
294
+
295
+ - `show: false` hides the category rows. `true` cannot show rows that the chart's own legend setting hides.
296
+ - `content` chooses what each row shows: `'nameAndPrice'` (default), `'name'`, or `'price'`. A price-only row shows the name when its category has no price.
297
+ - `hideAccessibleSeatsFilter: true` removes the Accessible seats filter, which otherwise appears on charts with wheelchair or companion seats.
298
+ - `hideUnavailableItem: true` removes the "Not available" row that follows the categories. The row shows the grey that sold, held and unavailable seats are drawn in.
299
+ - `hideNonSelectableCategories: true` hides a category while nothing in it can be selected: every seat is sold, held, outside the buyer's channels or outside the category filter, and every GA area is sold out or has fewer places left than its smallest booking. While the buyer filters to accessible seats, only those seats count. A category returns as soon as something frees up. Seats and places in the buyer's own selection count as selectable; reaching the selection limit hides nothing.
300
+
301
+ Prices come from `chart.setCategoryMetadata({ [categoryId]: { price } })` and are shown as sent, so include a currency prefix if you want one. Changing `legend` remounts the chart; `changeConfig` does not accept it.
302
+
303
+ ### Block in view on phones
304
+
305
+ On screens up to 768px wide, block names leave the map once the buyer zooms in to seats. A bar along the bottom then names the block at the centre of the screen, with its categories and price, and that block gets the hover outline. The legend moves up to sit above the bar. The bar updates when the map comes to rest, not during a pan.
306
+
307
+ Set `showActiveBlockOnMobile: false` on a classic or Season mount to turn it off. Changing it remounts the chart; `changeConfig` does not accept it.