@kerusiweb/core 2.3.0 → 3.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/LICENSE +22 -22
- package/README.md +74 -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/index.d.ts +6 -2
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +6 -2
- package/dist/view/index.js.map +1 -1
- 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-card-placement.d.ts +60 -0
- package/dist/view/seat-card-placement.d.ts.map +1 -0
- package/dist/view/seat-card-placement.js +94 -0
- package/dist/view/seat-card-placement.js.map +1 -0
- package/dist/view/seat-card.d.ts +83 -0
- package/dist/view/seat-card.d.ts.map +1 -0
- package/dist/view/seat-card.js +68 -0
- package/dist/view/seat-card.js.map +1 -0
- package/dist/view/seat-glyph.d.ts +1 -1
- package/dist/view/seat-glyph.d.ts.map +1 -1
- package/dist/view/seat-hover.d.ts +90 -0
- package/dist/view/seat-hover.d.ts.map +1 -0
- package/dist/view/seat-hover.js +205 -0
- package/dist/view/seat-hover.js.map +1 -0
- 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
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { canHover } from './seat-card.js';
|
|
2
|
+
export const IDLE_SEAT_HOVER = Object.freeze({
|
|
3
|
+
hoveredId: null,
|
|
4
|
+
suppressed: false,
|
|
5
|
+
cardId: null,
|
|
6
|
+
cardTrigger: null,
|
|
7
|
+
pendingId: null,
|
|
8
|
+
closing: false,
|
|
9
|
+
overCard: false,
|
|
10
|
+
focusedId: null,
|
|
11
|
+
dismissedId: null,
|
|
12
|
+
});
|
|
13
|
+
export function reduceSeatHover(state, event, delay) {
|
|
14
|
+
switch (event.type) {
|
|
15
|
+
case 'enter':
|
|
16
|
+
case 'move':
|
|
17
|
+
return canHover(event.pointerType) ? onPointerOver(state, event.seatId, delay) : { state };
|
|
18
|
+
case 'leave':
|
|
19
|
+
return canHover(event.pointerType) ? onPointerOut(state, event.seatId, delay) : { state };
|
|
20
|
+
case 'gesture':
|
|
21
|
+
return onGesture(state);
|
|
22
|
+
case 'card-enter':
|
|
23
|
+
return state.cardId === null
|
|
24
|
+
? { state }
|
|
25
|
+
: { state: { ...state, overCard: true, closing: false }, timer: { action: 'clear' } };
|
|
26
|
+
case 'card-leave':
|
|
27
|
+
return onCardLeave(state, delay);
|
|
28
|
+
case 'focus':
|
|
29
|
+
return onFocus(state, event.seatId);
|
|
30
|
+
case 'blur':
|
|
31
|
+
return onBlur(state, event.seatId);
|
|
32
|
+
case 'escape':
|
|
33
|
+
return onEscape(state);
|
|
34
|
+
case 'timer':
|
|
35
|
+
return onTimer(state, event.kind);
|
|
36
|
+
case 'reset':
|
|
37
|
+
return state === IDLE_SEAT_HOVER
|
|
38
|
+
? { state }
|
|
39
|
+
: {
|
|
40
|
+
state: IDLE_SEAT_HOVER,
|
|
41
|
+
timer: { action: 'clear' },
|
|
42
|
+
report: state.hoveredId === null ? undefined : { seatId: null },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function onPointerOver(state, seatId, delay) {
|
|
47
|
+
if (state.hoveredId === seatId && !state.suppressed) {
|
|
48
|
+
return { state };
|
|
49
|
+
}
|
|
50
|
+
const resumed = { ...state, suppressed: false, hoveredId: seatId };
|
|
51
|
+
const report = { seatId };
|
|
52
|
+
if (state.dismissedId === seatId) {
|
|
53
|
+
return { state: resumed, report };
|
|
54
|
+
}
|
|
55
|
+
// Already showing this seat's card (the pointer came back during the close
|
|
56
|
+
// delay, or the card was opened by focus): keep it.
|
|
57
|
+
if (state.cardId === seatId) {
|
|
58
|
+
return {
|
|
59
|
+
state: { ...resumed, closing: false, pendingId: null },
|
|
60
|
+
report,
|
|
61
|
+
timer: { action: 'clear' },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Another seat's card is showing: move to this one at once, so sweeping
|
|
65
|
+
// across a row does not flicker the card through its open delay each time.
|
|
66
|
+
if (state.cardId !== null) {
|
|
67
|
+
return {
|
|
68
|
+
state: {
|
|
69
|
+
...resumed,
|
|
70
|
+
cardId: seatId,
|
|
71
|
+
cardTrigger: 'hover',
|
|
72
|
+
closing: false,
|
|
73
|
+
overCard: false,
|
|
74
|
+
pendingId: null,
|
|
75
|
+
},
|
|
76
|
+
report,
|
|
77
|
+
timer: { action: 'clear' },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (delay.open <= 0) {
|
|
81
|
+
return {
|
|
82
|
+
state: { ...resumed, cardId: seatId, cardTrigger: 'hover', pendingId: null },
|
|
83
|
+
report,
|
|
84
|
+
timer: { action: 'clear' },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
state: { ...resumed, pendingId: seatId },
|
|
89
|
+
report,
|
|
90
|
+
timer: { action: 'start', kind: 'open', ms: delay.open },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function onPointerOut(state, seatId, delay) {
|
|
94
|
+
if (state.hoveredId !== seatId) {
|
|
95
|
+
return { state };
|
|
96
|
+
}
|
|
97
|
+
const left = {
|
|
98
|
+
...state,
|
|
99
|
+
hoveredId: null,
|
|
100
|
+
pendingId: null,
|
|
101
|
+
dismissedId: state.dismissedId === seatId && state.focusedId !== seatId ? null : state.dismissedId,
|
|
102
|
+
};
|
|
103
|
+
const report = { seatId: null };
|
|
104
|
+
// A card the pointer opened lingers for the close delay, so the pointer can
|
|
105
|
+
// travel into it. One that focus opened stays with the focus.
|
|
106
|
+
if (state.cardId === seatId && state.cardTrigger === 'hover' && !state.overCard) {
|
|
107
|
+
if (delay.close <= 0) {
|
|
108
|
+
return { state: closeCard(left), report, timer: { action: 'clear' } };
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
state: { ...left, closing: true },
|
|
112
|
+
report,
|
|
113
|
+
timer: { action: 'start', kind: 'close', ms: delay.close },
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
state: left,
|
|
118
|
+
report,
|
|
119
|
+
timer: state.pendingId === null && !state.closing ? undefined : { action: 'clear' },
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function onGesture(state) {
|
|
123
|
+
const hadHover = state.hoveredId !== null;
|
|
124
|
+
return {
|
|
125
|
+
state: { ...closeCard(state), hoveredId: null, pendingId: null, suppressed: true },
|
|
126
|
+
report: hadHover ? { seatId: null } : undefined,
|
|
127
|
+
timer: { action: 'clear' },
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function onCardLeave(state, delay) {
|
|
131
|
+
if (!state.overCard) {
|
|
132
|
+
return { state };
|
|
133
|
+
}
|
|
134
|
+
const off = { ...state, overCard: false };
|
|
135
|
+
// Back on the seat, or the card is held open by focus: nothing to close.
|
|
136
|
+
if (state.cardId === null || state.cardTrigger !== 'hover' || state.hoveredId === state.cardId) {
|
|
137
|
+
return { state: off };
|
|
138
|
+
}
|
|
139
|
+
if (delay.close <= 0) {
|
|
140
|
+
return { state: closeCard(off), timer: { action: 'clear' } };
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
state: { ...off, closing: true },
|
|
144
|
+
timer: { action: 'start', kind: 'close', ms: delay.close },
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function onFocus(state, seatId) {
|
|
148
|
+
const focused = { ...state, focusedId: seatId };
|
|
149
|
+
if (state.dismissedId === seatId || state.cardId === seatId) {
|
|
150
|
+
return { state: focused };
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
state: {
|
|
154
|
+
...focused,
|
|
155
|
+
cardId: seatId,
|
|
156
|
+
cardTrigger: 'focus',
|
|
157
|
+
pendingId: null,
|
|
158
|
+
closing: false,
|
|
159
|
+
overCard: false,
|
|
160
|
+
},
|
|
161
|
+
timer: { action: 'clear' },
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function onBlur(state, seatId) {
|
|
165
|
+
if (state.focusedId !== seatId) {
|
|
166
|
+
return { state };
|
|
167
|
+
}
|
|
168
|
+
const blurred = {
|
|
169
|
+
...state,
|
|
170
|
+
focusedId: null,
|
|
171
|
+
dismissedId: state.dismissedId === seatId && state.hoveredId !== seatId ? null : state.dismissedId,
|
|
172
|
+
};
|
|
173
|
+
if (state.cardId !== seatId || state.cardTrigger !== 'focus') {
|
|
174
|
+
return { state: blurred };
|
|
175
|
+
}
|
|
176
|
+
// The pointer is still on the seat: the card carries on as a hover card.
|
|
177
|
+
if (state.hoveredId === seatId) {
|
|
178
|
+
return { state: { ...blurred, cardTrigger: 'hover' } };
|
|
179
|
+
}
|
|
180
|
+
return { state: closeCard(blurred), timer: { action: 'clear' } };
|
|
181
|
+
}
|
|
182
|
+
function onEscape(state) {
|
|
183
|
+
if (state.cardId === null && state.pendingId === null) {
|
|
184
|
+
return { state };
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
state: { ...closeCard(state), pendingId: null, dismissedId: state.cardId ?? state.pendingId },
|
|
188
|
+
timer: { action: 'clear' },
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function onTimer(state, kind) {
|
|
192
|
+
if (kind === 'open' && state.pendingId !== null) {
|
|
193
|
+
return {
|
|
194
|
+
state: { ...state, cardId: state.pendingId, cardTrigger: 'hover', pendingId: null },
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (kind === 'close' && state.closing) {
|
|
198
|
+
return { state: closeCard(state) };
|
|
199
|
+
}
|
|
200
|
+
return { state };
|
|
201
|
+
}
|
|
202
|
+
function closeCard(state) {
|
|
203
|
+
return { ...state, cardId: null, cardTrigger: null, closing: false, overCard: false };
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=seat-hover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seat-hover.js","sourceRoot":"","sources":["../../src/view/seat-hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,gBAAgB,CAAC;AA4C/D,MAAM,CAAC,MAAM,eAAe,GAAmB,MAAM,CAAC,MAAM,CAAC;IAC3D,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,IAAI;IACZ,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AA2BH,MAAM,UAAU,eAAe,CAC7B,KAAqB,EACrB,KAAqB,EACrB,KAAqB;IAErB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QAC7F,KAAK,OAAO;YACV,OAAO,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QAC5F,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;QAC1B,K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}
|
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;AACp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E,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,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,GA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AA4E;AAC5E,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
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.1.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"}
|