@kerusiweb/core 2.3.0 → 3.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/LICENSE +22 -22
- package/README.md +70 -68
- package/dist/kerusi/index.d.ts +4 -3
- package/dist/kerusi/index.d.ts.map +1 -1
- package/dist/kerusi/index.js +4 -3
- package/dist/kerusi/index.js.map +1 -1
- package/dist/kerusi/kerusi-geometry.d.ts +47 -0
- package/dist/kerusi/kerusi-geometry.d.ts.map +1 -0
- package/dist/kerusi/kerusi-geometry.js +111 -0
- package/dist/kerusi/kerusi-geometry.js.map +1 -0
- package/dist/kerusi/kerusi-map.model.d.ts +121 -68
- package/dist/kerusi/kerusi-map.model.d.ts.map +1 -1
- package/dist/kerusi/kerusi-map.model.js +6 -2
- package/dist/kerusi/kerusi-map.model.js.map +1 -1
- package/dist/kerusi/kerusi-rows.d.ts +2 -2
- package/dist/kerusi/kerusi-rows.js +2 -2
- package/dist/kerusi/kerusi-validator.d.ts +18 -9
- package/dist/kerusi/kerusi-validator.d.ts.map +1 -1
- package/dist/kerusi/kerusi-validator.js +301 -122
- package/dist/kerusi/kerusi-validator.js.map +1 -1
- package/dist/render/build-render-model.d.ts +8 -4
- package/dist/render/build-render-model.d.ts.map +1 -1
- package/dist/render/build-render-model.js +147 -45
- package/dist/render/build-render-model.js.map +1 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/index.js.map +1 -1
- package/dist/render/map-layout.d.ts +92 -0
- package/dist/render/map-layout.d.ts.map +1 -0
- package/dist/render/map-layout.js +93 -0
- package/dist/render/map-layout.js.map +1 -0
- package/dist/render/navigation-order.d.ts +20 -10
- package/dist/render/navigation-order.d.ts.map +1 -1
- package/dist/render/navigation-order.js +72 -57
- package/dist/render/navigation-order.js.map +1 -1
- package/dist/render/render-model.d.ts +48 -26
- package/dist/render/render-model.d.ts.map +1 -1
- package/dist/render/seat-shapes.d.ts +3 -3
- package/dist/render/seat-shapes.js +3 -3
- package/dist/view/rtl.d.ts +1 -1
- package/dist/view/rtl.js +1 -1
- package/dist/view/seat-aria.d.ts +6 -0
- package/dist/view/seat-aria.d.ts.map +1 -1
- package/dist/view/seat-aria.js +8 -0
- package/dist/view/seat-aria.js.map +1 -1
- package/dist/view/seat-glyph.d.ts +1 -1
- package/dist/view/seat-glyph.d.ts.map +1 -1
- package/dist/view/viewport.d.ts +35 -7
- package/dist/view/viewport.d.ts.map +1 -1
- package/dist/view/viewport.js +56 -7
- package/dist/view/viewport.js.map +1 -1
- package/package.json +42 -42
- package/dist/kerusi/kerusi-layout-mode.d.ts +0 -58
- package/dist/kerusi/kerusi-layout-mode.d.ts.map +0 -1
- package/dist/kerusi/kerusi-layout-mode.js +0 -117
- package/dist/kerusi/kerusi-layout-mode.js.map +0 -1
- package/dist/render/section-layout.d.ts +0 -66
- package/dist/render/section-layout.d.ts.map +0 -1
- package/dist/render/section-layout.js +0 -186
- package/dist/render/section-layout.js.map +0 -1
package/dist/view/seat-aria.js
CHANGED
|
@@ -2,6 +2,7 @@ import { formatMoney } from '../kerusi/kerusi-locale.js';
|
|
|
2
2
|
export const DEFAULT_SEAT_ARIA_STRINGS = {
|
|
3
3
|
rowSeat: (row, seat) => `Row ${row}, seat ${seat}`,
|
|
4
4
|
seatOnly: (seat) => `Seat ${seat}`,
|
|
5
|
+
besideAisle: 'next to an aisle',
|
|
5
6
|
noPrice: 'no price',
|
|
6
7
|
available: 'available',
|
|
7
8
|
booked: 'booked, unavailable',
|
|
@@ -27,10 +28,17 @@ export const DEFAULT_SEAT_ARIA_STRINGS = {
|
|
|
27
28
|
* Builds a seat's accessible name, in the order a listener needs it: where the
|
|
28
29
|
* seat is, what kind it is, what it costs, whether it can be had, what
|
|
29
30
|
* accessibility it offers, and finally its descriptive tags.
|
|
31
|
+
*
|
|
32
|
+
* "Where" comes from the document's row and adjacency, never from `x`/`y`: an
|
|
33
|
+
* aisle is mentioned when the next seat along the row skips a `col` (§4.3.5),
|
|
34
|
+
* which is also where the arrow keys jump across it.
|
|
30
35
|
*/
|
|
31
36
|
export function seatAriaLabel(seat, locale, strings = DEFAULT_SEAT_ARIA_STRINGS) {
|
|
32
37
|
const parts = [];
|
|
33
38
|
parts.push(seat.rowLabel ? strings.rowSeat(seat.rowLabel, seat.label) : strings.seatOnly(seat.label));
|
|
39
|
+
if (seat.besideAisle) {
|
|
40
|
+
parts.push(strings.besideAisle);
|
|
41
|
+
}
|
|
34
42
|
if (seat.typeLabel && seat.typeLabel !== seat.type.id) {
|
|
35
43
|
parts.push(seat.typeLabel);
|
|
36
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-aria.js","sourceRoot":"","sources":["../../src/view/seat-aria.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"seat-aria.js","sourceRoot":"","sources":["../../src/view/seat-aria.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAsCzD,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,GAAG,UAAU,IAAI,EAAE;IAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE;IAClC,WAAW,EAAE,kBAAkB;IAC/B,OAAO,EAAE,UAAU;IACnB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,qBAAqB;IAC7B,IAAI,EAAE,sBAAsB;IAC5B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,eAAe;IACzD,OAAO,EAAE,mCAAmC;IAC5C,oBAAoB,EAAE,uBAAuB;IAC7C,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,IAAI,EAAE;IACrD,o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AK,GAAG,IAAI,CAAC,QAAQ;QACzB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC;QAC5C,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC;AACnD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RenderSeat } from '../render/render-model.js';
|
|
2
2
|
import { SeatBox } from '../render/seat-shapes.js';
|
|
3
|
-
import { PlacedSeat } from '../render/
|
|
3
|
+
import { PlacedSeat } from '../render/map-layout.js';
|
|
4
4
|
import { KerusiSeatStyle } from './kerusi-seat-style.js';
|
|
5
5
|
import { KerusiSeatmapColors, SeatOccupantVariant } from './kerusi-seatmap-colors.js';
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-glyph.d.ts","sourceRoot":"","sources":["../../src/view/seat-glyph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACL,OAAO,EAMR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"seat-glyph.d.ts","sourceRoot":"","sources":["../../src/view/seat-glyph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACL,OAAO,EAMR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAa,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,mBAAmB,EAGnB,mBAAmB,EAMpB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;GAUG;AAEH,qBAAqB;AAC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jC,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,MAAM,EAAE,UAAU,CAAC;IACnB,gFAAgF;IAChF,IAAI,EAAE,UAAU,CAAC;IACjB,oDAAoD;IACpD,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,KAAK,EAAE,SAAS,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACrC,UAAU,EAAE,OAAO,EACnB,KAAK,CAAC,EAAE,eAAe,GACtB,SAAS,CAmEX;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAGpB;AAaD,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,kBAAkB,CAQvE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,EACjB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GACjC,MAAM,CAYR"}
|
package/dist/view/viewport.d.ts
CHANGED
|
@@ -7,8 +7,15 @@
|
|
|
7
7
|
* The bindings own the measuring and the event listeners; this owns what a
|
|
8
8
|
* wheel tick, a key press or a pinch *means*.
|
|
9
9
|
*
|
|
10
|
-
* Zoom 1 is "fit": the
|
|
11
|
-
* the minimum, so the map can never be shrunk below the
|
|
10
|
+
* Zoom 1 is "fit": the whole canvas (§4.5) exactly as it lays out without
|
|
11
|
+
* zooming. It is also the minimum, so the map can never be shrunk below the
|
|
12
|
+
* container.
|
|
13
|
+
*
|
|
14
|
+
* Positions come in two frames. *Content* coordinates are CSS pixels on the
|
|
15
|
+
* unzoomed map, with the canvas's top-left at the origin; convert a canvas
|
|
16
|
+
* rect, such as a section's bounds or a placed seat, with
|
|
17
|
+
* {@link canvasRectToContent}. *Container* coordinates are where something is
|
|
18
|
+
* on screen now, relative to the container.
|
|
12
19
|
*/
|
|
13
20
|
/** Zoom and pan of the map, as a CSS transform about its top-left corner. */
|
|
14
21
|
export interface KerusiViewport {
|
|
@@ -32,7 +39,7 @@ export interface ViewportLimits {
|
|
|
32
39
|
minZoom: number;
|
|
33
40
|
maxZoom: number;
|
|
34
41
|
}
|
|
35
|
-
/** The
|
|
42
|
+
/** The whole canvas exactly as laid out: no zoom, no pan. */
|
|
36
43
|
export declare const FIT_VIEWPORT: KerusiViewport;
|
|
37
44
|
/** Zoom is relative to fit, so the floor is always 1. */
|
|
38
45
|
export declare const MIN_ZOOM = 1;
|
|
@@ -72,16 +79,37 @@ export declare function zoomViewportBy(viewport: KerusiViewport, factor: number,
|
|
|
72
79
|
export declare function stepViewport(viewport: KerusiViewport, direction: 1 | -1, content: ViewportSize, container: ViewportSize, limits?: ViewportLimits): KerusiViewport;
|
|
73
80
|
/** Pans by a delta in CSS pixels, held inside the map's bounds. */
|
|
74
81
|
export declare function panViewportBy(viewport: KerusiViewport, dx: number, dy: number, content: ViewportSize, container: ViewportSize, limits?: ViewportLimits): KerusiViewport;
|
|
82
|
+
/**
|
|
83
|
+
* A rect in canvas units — a section's bounds, a placed seat — in content
|
|
84
|
+
* coordinates, given the canvas and the size the map lays out at when unzoomed.
|
|
85
|
+
* The canvas has the same scale on both axes (§4.5), and so does a map laid
|
|
86
|
+
* out at its aspect ratio; each axis is scaled on its own regardless, so a
|
|
87
|
+
* stretched layout still lands where it is drawn.
|
|
88
|
+
*/
|
|
89
|
+
export declare function canvasRectToContent(rect: ViewportRect, canvas: ViewportSize, content: ViewportSize): ViewportRect;
|
|
90
|
+
/** Where a rect in content coordinates is on screen under `viewport`, in container coordinates. */
|
|
91
|
+
export declare function contentRectToContainer(viewport: KerusiViewport, rect: ViewportRect): ViewportRect;
|
|
92
|
+
/**
|
|
93
|
+
* The viewport that shows `rect` as large as the container allows, centred on
|
|
94
|
+
* it, with a margin: zoom to a section's bounds. `rect` is in content
|
|
95
|
+
* coordinates. The zoom stays within the limits, so a rect bigger than the
|
|
96
|
+
* container at fit gives fit, and the pan stays within the map.
|
|
97
|
+
*/
|
|
98
|
+
export declare function viewportForRect(rect: ViewportRect, content: ViewportSize, container: ViewportSize, margin?: number, limits?: ViewportLimits): KerusiViewport;
|
|
75
99
|
/**
|
|
76
100
|
* Pans just far enough to bring `rect` inside the container, with a margin.
|
|
77
101
|
*
|
|
78
102
|
* `rect` is where the thing is on screen *now*, in container coordinates — a
|
|
79
|
-
* seat's bounding box minus the container's.
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* bigger than the container is aligned by its leading edge.
|
|
103
|
+
* seat's bounding box minus the container's. A rect bigger than the container
|
|
104
|
+
* is aligned by its leading edge. To reveal something from where it is on the
|
|
105
|
+
* canvas instead, without measuring, use {@link revealContentRect}.
|
|
83
106
|
*/
|
|
84
107
|
export declare function revealRect(viewport: KerusiViewport, rect: ViewportRect, content: ViewportSize, container: ViewportSize, margin?: number, limits?: ViewportLimits): KerusiViewport;
|
|
108
|
+
/**
|
|
109
|
+
* Pans just far enough to bring `rect`, in content coordinates, inside the
|
|
110
|
+
* container: reveal a focused seat from its placed position on the canvas.
|
|
111
|
+
*/
|
|
112
|
+
export declare function revealContentRect(viewport: KerusiViewport, rect: ViewportRect, content: ViewportSize, container: ViewportSize, margin?: number, limits?: ViewportLimits): KerusiViewport;
|
|
85
113
|
/**
|
|
86
114
|
* The zoom factor a wheel event asks for, or `null` if it is not a zoom
|
|
87
115
|
* gesture.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../src/view/viewport.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../src/view/viewport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa,EAAE,YAAY;CAAG;AAEpE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,eAAO,MAAM,YAAY,EAAE,cAAuD,CAAC;AAEnF,yDAAyD;AACzD,eAAO,MAAM,QAAQ,IAAI,CAAC;AAE1B,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,mFAAmF;AACnF,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B,gDAAgD;AAChD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,oFAAoF;AACpF,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,6FAA6F;AAC7F,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,wFAAwF;AACxF,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,OAAO,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AE,gBAAgB,EACvB,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,YAAY,EACvB,MAAM,GAAE,cAA6B,GACpC,cAAc,GAAG,IAAI,CA8BvB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAC3E,OAAO,CAQT;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,GAAG,OAAO,CAI5E;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAElE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAExF"}
|
package/dist/view/viewport.js
CHANGED
|
@@ -7,10 +7,17 @@
|
|
|
7
7
|
* The bindings own the measuring and the event listeners; this owns what a
|
|
8
8
|
* wheel tick, a key press or a pinch *means*.
|
|
9
9
|
*
|
|
10
|
-
* Zoom 1 is "fit": the
|
|
11
|
-
* the minimum, so the map can never be shrunk below the
|
|
10
|
+
* Zoom 1 is "fit": the whole canvas (§4.5) exactly as it lays out without
|
|
11
|
+
* zooming. It is also the minimum, so the map can never be shrunk below the
|
|
12
|
+
* container.
|
|
13
|
+
*
|
|
14
|
+
* Positions come in two frames. *Content* coordinates are CSS pixels on the
|
|
15
|
+
* unzoomed map, with the canvas's top-left at the origin; convert a canvas
|
|
16
|
+
* rect, such as a section's bounds or a placed seat, with
|
|
17
|
+
* {@link canvasRectToContent}. *Container* coordinates are where something is
|
|
18
|
+
* on screen now, relative to the container.
|
|
12
19
|
*/
|
|
13
|
-
/** The
|
|
20
|
+
/** The whole canvas exactly as laid out: no zoom, no pan. */
|
|
14
21
|
export const FIT_VIEWPORT = Object.freeze({ zoom: 1, x: 0, y: 0 });
|
|
15
22
|
/** Zoom is relative to fit, so the floor is always 1. */
|
|
16
23
|
export const MIN_ZOOM = 1;
|
|
@@ -78,20 +85,62 @@ export function stepViewport(viewport, direction, content, container, limits = z
|
|
|
78
85
|
export function panViewportBy(viewport, dx, dy, content, container, limits = zoomLimits()) {
|
|
79
86
|
return clampViewport({ zoom: viewport.zoom, x: viewport.x + dx, y: viewport.y + dy }, content, container, limits);
|
|
80
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* A rect in canvas units — a section's bounds, a placed seat — in content
|
|
90
|
+
* coordinates, given the canvas and the size the map lays out at when unzoomed.
|
|
91
|
+
* The canvas has the same scale on both axes (§4.5), and so does a map laid
|
|
92
|
+
* out at its aspect ratio; each axis is scaled on its own regardless, so a
|
|
93
|
+
* stretched layout still lands where it is drawn.
|
|
94
|
+
*/
|
|
95
|
+
export function canvasRectToContent(rect, canvas, content) {
|
|
96
|
+
const sx = canvas.width > 0 ? content.width / canvas.width : 0;
|
|
97
|
+
const sy = canvas.height > 0 ? content.height / canvas.height : 0;
|
|
98
|
+
return { x: rect.x * sx, y: rect.y * sy, width: rect.width * sx, height: rect.height * sy };
|
|
99
|
+
}
|
|
100
|
+
/** Where a rect in content coordinates is on screen under `viewport`, in container coordinates. */
|
|
101
|
+
export function contentRectToContainer(viewport, rect) {
|
|
102
|
+
return {
|
|
103
|
+
x: viewport.x + rect.x * viewport.zoom,
|
|
104
|
+
y: viewport.y + rect.y * viewport.zoom,
|
|
105
|
+
width: rect.width * viewport.zoom,
|
|
106
|
+
height: rect.height * viewport.zoom,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The viewport that shows `rect` as large as the container allows, centred on
|
|
111
|
+
* it, with a margin: zoom to a section's bounds. `rect` is in content
|
|
112
|
+
* coordinates. The zoom stays within the limits, so a rect bigger than the
|
|
113
|
+
* container at fit gives fit, and the pan stays within the map.
|
|
114
|
+
*/
|
|
115
|
+
export function viewportForRect(rect, content, container, margin = REVEAL_MARGIN, limits = zoomLimits()) {
|
|
116
|
+
const fits = (available, size) => size > 0 ? Math.max(available - 2 * Math.max(0, margin), 0) / size : Number.POSITIVE_INFINITY;
|
|
117
|
+
const zoom = clamp(Math.min(fits(container.width, rect.width), fits(container.height, rect.height)), limits.minZoom, limits.maxZoom);
|
|
118
|
+
return clampViewport({
|
|
119
|
+
zoom,
|
|
120
|
+
x: container.width / 2 - (rect.x + rect.width / 2) * zoom,
|
|
121
|
+
y: container.height / 2 - (rect.y + rect.height / 2) * zoom,
|
|
122
|
+
}, content, container, limits);
|
|
123
|
+
}
|
|
81
124
|
/**
|
|
82
125
|
* Pans just far enough to bring `rect` inside the container, with a margin.
|
|
83
126
|
*
|
|
84
127
|
* `rect` is where the thing is on screen *now*, in container coordinates — a
|
|
85
|
-
* seat's bounding box minus the container's.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* bigger than the container is aligned by its leading edge.
|
|
128
|
+
* seat's bounding box minus the container's. A rect bigger than the container
|
|
129
|
+
* is aligned by its leading edge. To reveal something from where it is on the
|
|
130
|
+
* canvas instead, without measuring, use {@link revealContentRect}.
|
|
89
131
|
*/
|
|
90
132
|
export function revealRect(viewport, rect, content, container, margin = REVEAL_MARGIN, limits = zoomLimits()) {
|
|
91
133
|
const dx = revealAxis(rect.x, rect.width, container.width, margin);
|
|
92
134
|
const dy = revealAxis(rect.y, rect.height, container.height, margin);
|
|
93
135
|
return panViewportBy(viewport, dx, dy, content, container, limits);
|
|
94
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Pans just far enough to bring `rect`, in content coordinates, inside the
|
|
139
|
+
* container: reveal a focused seat from its placed position on the canvas.
|
|
140
|
+
*/
|
|
141
|
+
export function revealContentRect(viewport, rect, content, container, margin = REVEAL_MARGIN, limits = zoomLimits()) {
|
|
142
|
+
return revealRect(viewport, contentRectToContainer(viewport, rect), content, container, margin, limits);
|
|
143
|
+
}
|
|
95
144
|
/**
|
|
96
145
|
* The zoom factor a wheel event asks for, or `null` if it is not a zoom
|
|
97
146
|
* gesture.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../src/view/viewport.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../src/view/viewport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA4BH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAmB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnF,yDAAyD;AACzD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAE1B,wFAAwF;AACxF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,mFAAmF;AACnF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAE7B,gDAAgD;AAChD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C,wFAAwF;AACxF,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,sFAAsF;AACtF,MAAM,UAAU,UAAU,CAAC,UAAkB,gBAAgB;IAC3D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;AACjG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAwB,EACxB,OAAqB,EACrB,SAAuB,EACvB,SAAyB,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
|
1
|
-
{
|
|
2
|
-
"name": "@kerusiweb/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Framework-agnostic core for the Kerusi Seat Map & Availability Format: document types, a conformance validator, and the render model and geometry a seat-map renderer consumes.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"kerusi",
|
|
7
|
-
"seat-map",
|
|
8
|
-
"seatmap",
|
|
9
|
-
"seat-picker",
|
|
10
|
-
"seat-selection",
|
|
11
|
-
"booking",
|
|
12
|
-
"ticketing",
|
|
13
|
-
"cinema",
|
|
14
|
-
"airline",
|
|
15
|
-
"venue"
|
|
16
|
-
],
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"author": "Arsyad \"Shad Ahm\" Ahmad",
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "https://github.com/ShadAhm/kerusiweb.git",
|
|
22
|
-
"directory": "projects/core"
|
|
23
|
-
},
|
|
24
|
-
"homepage": "https://github.com/ShadAhm/kerusiweb",
|
|
25
|
-
"type": "module",
|
|
26
|
-
"sideEffects": false,
|
|
27
|
-
"exports": {
|
|
28
|
-
".": {
|
|
29
|
-
"types": "./dist/public-api.d.ts",
|
|
30
|
-
"default": "./dist/public-api.js"
|
|
31
|
-
},
|
|
32
|
-
"./package.json": "./package.json"
|
|
33
|
-
},
|
|
34
|
-
"types": "./dist/public-api.d.ts",
|
|
35
|
-
"main": "./dist/public-api.js",
|
|
36
|
-
"files": [
|
|
37
|
-
"dist"
|
|
38
|
-
],
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@kerusiweb/core",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Framework-agnostic core for the Kerusi Seat Map & Availability Format: document types, a conformance validator, and the render model and geometry a seat-map renderer consumes.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"kerusi",
|
|
7
|
+
"seat-map",
|
|
8
|
+
"seatmap",
|
|
9
|
+
"seat-picker",
|
|
10
|
+
"seat-selection",
|
|
11
|
+
"booking",
|
|
12
|
+
"ticketing",
|
|
13
|
+
"cinema",
|
|
14
|
+
"airline",
|
|
15
|
+
"venue"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Arsyad \"Shad Ahm\" Ahmad",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/ShadAhm/kerusiweb.git",
|
|
22
|
+
"directory": "projects/core"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/ShadAhm/kerusiweb",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/public-api.d.ts",
|
|
30
|
+
"default": "./dist/public-api.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/public-api.d.ts",
|
|
35
|
+
"main": "./dist/public-api.js",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Section } from './kerusi-map.model.js';
|
|
2
|
-
import { KerusiViolation } from './kerusi-violation.js';
|
|
3
|
-
/** The three positioning modes a section may use (§4.5). */
|
|
4
|
-
export type SectionLayoutMode = 'grid' | 'freeform' | 'mixed';
|
|
5
|
-
/**
|
|
6
|
-
* `Section.layout` is a strict, validated constraint — not a rendering hint.
|
|
7
|
-
* This module is the single implementation of §4.5, shared by the validator and
|
|
8
|
-
* the render-model builder so the two can never disagree about what mode a
|
|
9
|
-
* section is in.
|
|
10
|
-
*
|
|
11
|
-
* Per §4.5:
|
|
12
|
-
* - `grid` — every seat MUST have `col`; no seat may have `x` or `y`.
|
|
13
|
-
* - `freeform` — every seat MUST have both `x` and `y`; no seat may have `col`.
|
|
14
|
-
* - `mixed` — every seat MUST have `col` AND both `x` and `y`.
|
|
15
|
-
*
|
|
16
|
-
* A free-text `row` is permitted in every mode: it carries no positional
|
|
17
|
-
* information, so it never participates in the constraint.
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* The positional members a seat or element may carry. Elements are positioned
|
|
21
|
-
* the same way seats are (§4.4), so these predicates take the shape rather than
|
|
22
|
-
* the full `Seat`.
|
|
23
|
-
*/
|
|
24
|
-
export interface Positioned {
|
|
25
|
-
col?: number;
|
|
26
|
-
x?: number;
|
|
27
|
-
y?: number;
|
|
28
|
-
}
|
|
29
|
-
/** True when the item carries a usable grid column. */
|
|
30
|
-
export declare function hasCol(item: Positioned): boolean;
|
|
31
|
-
/** True when the item carries both freeform coordinates. Neither alone counts. */
|
|
32
|
-
export declare function hasXY(item: Positioned): boolean;
|
|
33
|
-
/** True when the item carries either coordinate — the `grid` prohibition. */
|
|
34
|
-
export declare function hasAnyCoordinate(item: Positioned): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Infers a section's mode from its seats when `Section.layout` is omitted
|
|
37
|
-
* (§4.5). Returns `undefined` when the seats are inconsistent — the caller MUST
|
|
38
|
-
* reject such a section.
|
|
39
|
-
*
|
|
40
|
-
* An empty section infers `grid`: it satisfies "every seat has `col`" vacuously
|
|
41
|
-
* and grid is the cheaper mode to render.
|
|
42
|
-
*/
|
|
43
|
-
export declare function inferSectionLayoutMode(section: Section): SectionLayoutMode | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* The mode a section renders in: its declared `layout`, or the inferred one.
|
|
46
|
-
* Falls back to `grid` for an inconsistent section so a renderer can still draw
|
|
47
|
-
* *something* after the validator has reported the fault. Callers that must not
|
|
48
|
-
* render an invalid document should check {@link checkSectionLayout} first.
|
|
49
|
-
*/
|
|
50
|
-
export declare function resolveSectionLayoutMode(section: Section): SectionLayoutMode;
|
|
51
|
-
/**
|
|
52
|
-
* Validates a section against §4.5. Returns every violation found, in seat
|
|
53
|
-
* declaration order; an empty array means the section conforms.
|
|
54
|
-
*
|
|
55
|
-
* @param path Document path prefix for the violations, e.g. `sections[1]`.
|
|
56
|
-
*/
|
|
57
|
-
export declare function checkSectionLayout(section: Section, path?: string): KerusiViolation[];
|
|
58
|
-
//# sourceMappingURL=kerusi-layout-mode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kerusi-layout-mode.d.ts","sourceRoot":"","sources":["../../src/kerusi/kerusi-layout-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAS,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE/D,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED,uDAAuD;AACvD,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAEhD;AAED,kFAAkF;AAClF,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAE/C;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAE1D;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,CActF;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CA4FrF"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { error } from './kerusi-violation.js';
|
|
2
|
-
/** True when the item carries a usable grid column. */
|
|
3
|
-
export function hasCol(item) {
|
|
4
|
-
return item.col !== undefined && item.col !== null;
|
|
5
|
-
}
|
|
6
|
-
/** True when the item carries both freeform coordinates. Neither alone counts. */
|
|
7
|
-
export function hasXY(item) {
|
|
8
|
-
return item.x !== undefined && item.x !== null && item.y !== undefined && item.y !== null;
|
|
9
|
-
}
|
|
10
|
-
/** True when the item carries either coordinate — the `grid` prohibition. */
|
|
11
|
-
export function hasAnyCoordinate(item) {
|
|
12
|
-
return (item.x !== undefined && item.x !== null) || (item.y !== undefined && item.y !== null);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Infers a section's mode from its seats when `Section.layout` is omitted
|
|
16
|
-
* (§4.5). Returns `undefined` when the seats are inconsistent — the caller MUST
|
|
17
|
-
* reject such a section.
|
|
18
|
-
*
|
|
19
|
-
* An empty section infers `grid`: it satisfies "every seat has `col`" vacuously
|
|
20
|
-
* and grid is the cheaper mode to render.
|
|
21
|
-
*/
|
|
22
|
-
export function inferSectionLayoutMode(section) {
|
|
23
|
-
const seats = section.seats ?? [];
|
|
24
|
-
if (seats.length === 0) {
|
|
25
|
-
return 'grid';
|
|
26
|
-
}
|
|
27
|
-
if (seats.every((s) => hasCol(s) && !hasAnyCoordinate(s))) {
|
|
28
|
-
return 'grid';
|
|
29
|
-
}
|
|
30
|
-
if (seats.every((s) => hasXY(s) && !hasCol(s))) {
|
|
31
|
-
return 'freeform';
|
|
32
|
-
}
|
|
33
|
-
// The spec defines no inference for `mixed`; declaring it is required. Every
|
|
34
|
-
// other shape is inconsistent.
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The mode a section renders in: its declared `layout`, or the inferred one.
|
|
39
|
-
* Falls back to `grid` for an inconsistent section so a renderer can still draw
|
|
40
|
-
* *something* after the validator has reported the fault. Callers that must not
|
|
41
|
-
* render an invalid document should check {@link checkSectionLayout} first.
|
|
42
|
-
*/
|
|
43
|
-
export function resolveSectionLayoutMode(section) {
|
|
44
|
-
return section.layout ?? inferSectionLayoutMode(section) ?? 'grid';
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Validates a section against §4.5. Returns every violation found, in seat
|
|
48
|
-
* declaration order; an empty array means the section conforms.
|
|
49
|
-
*
|
|
50
|
-
* @param path Document path prefix for the violations, e.g. `sections[1]`.
|
|
51
|
-
*/
|
|
52
|
-
export function checkSectionLayout(section, path) {
|
|
53
|
-
const seats = section.seats ?? [];
|
|
54
|
-
if (section.layout === undefined) {
|
|
55
|
-
if (inferSectionLayoutMode(section) === undefined) {
|
|
56
|
-
const offender = firstInconsistentSeat(seats);
|
|
57
|
-
return [
|
|
58
|
-
error('section-layout-inconsistent', `Section "${section.id}" omits "layout" and its seats mix positioning ` +
|
|
59
|
-
`methods, so no mode can be inferred: seat "${offender?.id}" does not ` +
|
|
60
|
-
'match the section\'s prevailing method. Declare "layout" explicitly, ' +
|
|
61
|
-
'or make every seat use the same method (§4.5).', { id: section.id, path }),
|
|
62
|
-
];
|
|
63
|
-
}
|
|
64
|
-
// An inferred mode is, by construction, satisfied by every seat.
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
const violations = [];
|
|
68
|
-
seats.forEach((seat, i) => {
|
|
69
|
-
const seatPath = path ? `${path}.seats[${i}]` : undefined;
|
|
70
|
-
switch (section.layout) {
|
|
71
|
-
case 'grid':
|
|
72
|
-
if (!hasCol(seat)) {
|
|
73
|
-
violations.push(error('section-layout-grid', `Seat "${seat.id}" is in grid section "${section.id}" but has no ` +
|
|
74
|
-
'"col". Every seat in a grid section must declare "col" ' +
|
|
75
|
-
'explicitly; it is never inferred from array order (§4.5).', { id: seat.id, path: seatPath }));
|
|
76
|
-
}
|
|
77
|
-
if (hasAnyCoordinate(seat)) {
|
|
78
|
-
violations.push(error('section-layout-grid', `Seat "${seat.id}" is in grid section "${section.id}" but carries ` +
|
|
79
|
-
'"x"/"y". No seat in a grid section may have freeform ' +
|
|
80
|
-
'coordinates; use layout "mixed" to combine both (§4.5).', { id: seat.id, path: seatPath }));
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
case 'freeform':
|
|
84
|
-
if (!hasXY(seat)) {
|
|
85
|
-
violations.push(error('section-layout-freeform', `Seat "${seat.id}" is in freeform section "${section.id}" but is ` +
|
|
86
|
-
'missing "x" or "y". Every seat in a freeform section must have ' +
|
|
87
|
-
'both (§4.5).', { id: seat.id, path: seatPath }));
|
|
88
|
-
}
|
|
89
|
-
if (hasCol(seat)) {
|
|
90
|
-
violations.push(error('section-layout-freeform', `Seat "${seat.id}" is in freeform section "${section.id}" but ` +
|
|
91
|
-
'carries "col". No seat in a freeform section may have a grid ' +
|
|
92
|
-
'column; use layout "mixed" to combine both (§4.5).', { id: seat.id, path: seatPath }));
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
case 'mixed':
|
|
96
|
-
if (!hasCol(seat) || !hasXY(seat)) {
|
|
97
|
-
violations.push(error('section-layout-mixed', `Seat "${seat.id}" is in mixed section "${section.id}" but does not ` +
|
|
98
|
-
'have all of "col", "x" and "y". A mixed section requires every ' +
|
|
99
|
-
'seat to carry both addressing methods (§4.5).', { id: seat.id, path: seatPath }));
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
return violations;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* The first seat that breaks the section's prevailing positioning method, used
|
|
108
|
-
* to make an "inconsistent" message point at something concrete.
|
|
109
|
-
*/
|
|
110
|
-
function firstInconsistentSeat(seats) {
|
|
111
|
-
const gridLike = seats.filter((s) => hasCol(s) && !hasAnyCoordinate(s)).length;
|
|
112
|
-
const freeformLike = seats.filter((s) => hasXY(s) && !hasCol(s)).length;
|
|
113
|
-
return gridLike >= freeformLike
|
|
114
|
-
? seats.find((s) => !(hasCol(s) && !hasAnyCoordinate(s)))
|
|
115
|
-
: seats.find((s) => !(hasXY(s) && !hasCol(s)));
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=kerusi-layout-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kerusi-layout-mode.js","sourceRoot":"","sources":["../../src/kerusi/kerusi-layout-mode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAmB,MAAM,uBAAuB,CAAC;AA+B/D,uDAAuD;AACvD,MAAM,UAAU,MAAM,CAAC,IAAgB;IACrC,OAAO,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,KAAK,CAAC,IAAgB;IACpC,OAAO,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC;AAC5F,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,IAAgB;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AAChG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;IAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAA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EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { RenderElement, RenderSeat, RenderSection } from './render-model.js';
|
|
2
|
-
/**
|
|
3
|
-
* Section geometry: turning a `RenderSection` into placed rectangles.
|
|
4
|
-
*
|
|
5
|
-
* Each section computes its own *intrinsic* size — a grid section is as wide as
|
|
6
|
-
* its widest row and as tall as its row count; a freeform section takes its
|
|
7
|
-
* proportions from `Section.aspectRatio`. The component then hands that size to
|
|
8
|
-
* the SVG as a `viewBox` and lets CSS scale it. The pre-1.0 renderer instead
|
|
9
|
-
* stretched every layout to fill a fixed 500x500 canvas, which squashed a wide
|
|
10
|
-
* auditorium into flattened rectangles.
|
|
11
|
-
*/
|
|
12
|
-
export interface PlacedSeat {
|
|
13
|
-
seat: RenderSeat;
|
|
14
|
-
/** Top-left corner, in viewBox units. */
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
centerX: number;
|
|
20
|
-
centerY: number;
|
|
21
|
-
fontSize: number;
|
|
22
|
-
/** Degrees about the seat center; 0 unless the document asked for a tilt. */
|
|
23
|
-
rotation: number;
|
|
24
|
-
}
|
|
25
|
-
export interface PlacedElement {
|
|
26
|
-
element: RenderElement;
|
|
27
|
-
x: number;
|
|
28
|
-
y: number;
|
|
29
|
-
width: number;
|
|
30
|
-
height: number;
|
|
31
|
-
centerX: number;
|
|
32
|
-
centerY: number;
|
|
33
|
-
fontSize: number;
|
|
34
|
-
rotation: number;
|
|
35
|
-
}
|
|
36
|
-
export interface SectionLayout {
|
|
37
|
-
/** Intrinsic viewBox width. */
|
|
38
|
-
width: number;
|
|
39
|
-
/** Intrinsic viewBox height. */
|
|
40
|
-
height: number;
|
|
41
|
-
seats: readonly PlacedSeat[];
|
|
42
|
-
elements: readonly PlacedElement[];
|
|
43
|
-
}
|
|
44
|
-
export interface SectionLayoutOptions {
|
|
45
|
-
/** Grid cell edge, in viewBox units. */
|
|
46
|
-
seatSize?: number;
|
|
47
|
-
/** Gap between adjacent cells, in viewBox units. */
|
|
48
|
-
seatGap?: number;
|
|
49
|
-
/** Freeform viewBox width; height follows from the aspect ratio. */
|
|
50
|
-
freeformBasis?: number;
|
|
51
|
-
/** Overrides `Section.aspectRatio`. */
|
|
52
|
-
aspectRatio?: string;
|
|
53
|
-
/** Mirrors the grid horizontally, for right-to-left locales. */
|
|
54
|
-
rtl?: boolean;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Places a section's seats and elements. Dispatches on the section's own
|
|
58
|
-
* resolved layout mode, so a map may mix grid, freeform and mixed sections —
|
|
59
|
-
* the pre-1.0 adapter collapsed the whole map to a single mode.
|
|
60
|
-
*
|
|
61
|
-
* `mixed` is laid out as freeform: §4.3.1 makes `x`/`y` authoritative for
|
|
62
|
-
* visual placement when both are present. Its `col` survives on the seat and is
|
|
63
|
-
* consumed by `navigation-order.ts`.
|
|
64
|
-
*/
|
|
65
|
-
export declare function computeSectionLayout(section: RenderSection, options?: SectionLayoutOptions): SectionLayout;
|
|
66
|
-
//# sourceMappingURL=section-layout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"section-layout.d.ts","sourceRoot":"","sources":["../../src/render/section-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE7E;;;;;;;;;GASG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,yCAAyC;IACzC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,E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