@kerusiweb/core 2.2.0 → 2.3.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/dist/render/seat-shapes.d.ts +33 -0
- package/dist/render/seat-shapes.d.ts.map +1 -1
- package/dist/render/seat-shapes.js +47 -0
- package/dist/render/seat-shapes.js.map +1 -1
- package/dist/view/index.d.ts +2 -0
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +2 -0
- package/dist/view/index.js.map +1 -1
- package/dist/view/kerusi-seat-style.d.ts +58 -0
- package/dist/view/kerusi-seat-style.d.ts.map +1 -0
- package/dist/view/kerusi-seat-style.js +32 -0
- package/dist/view/kerusi-seat-style.js.map +1 -0
- package/dist/view/kerusi-seatmap-colors.d.ts +41 -5
- package/dist/view/kerusi-seatmap-colors.d.ts.map +1 -1
- package/dist/view/kerusi-seatmap-colors.js +67 -8
- package/dist/view/kerusi-seatmap-colors.js.map +1 -1
- package/dist/view/seat-glyph.d.ts +137 -0
- package/dist/view/seat-glyph.d.ts.map +1 -0
- package/dist/view/seat-glyph.js +130 -0
- package/dist/view/seat-glyph.js.map +1 -0
- package/package.json +1 -1
|
@@ -69,4 +69,37 @@ export declare const seatRingStroke: typeof seatSelectedFrame;
|
|
|
69
69
|
export declare function seatOccupantPath(x: number, y: number, width: number, height: number): string;
|
|
70
70
|
/** The stroke width for the held variant of {@link seatOccupantPath} — drawn hollow. */
|
|
71
71
|
export declare function seatOccupantStroke(width: number, height: number): number;
|
|
72
|
+
/** An axis-aligned box in viewBox units. */
|
|
73
|
+
export interface SeatBox {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The outline a seat is drawn with.
|
|
81
|
+
*
|
|
82
|
+
* - `'seat'`: the default tapered outline, {@link seatBodyPath}. The only one
|
|
83
|
+
* that shows which way a seat faces.
|
|
84
|
+
* - `'square'`: a square with the same slight corners as the seat's front.
|
|
85
|
+
* - `'rounded'`: a square with soft corners.
|
|
86
|
+
* - `'circle'`: a circle filling the box.
|
|
87
|
+
* - A function: given a box, return a closed path `d` inside it. It is called
|
|
88
|
+
* for the seat's box and again for the selected core's smaller box, so it
|
|
89
|
+
* must draw relative to the box it is given, not to fixed coordinates.
|
|
90
|
+
*/
|
|
91
|
+
export type KerusiSeatShape = 'seat' | 'square' | 'rounded' | 'circle' | ((box: SeatBox) => string);
|
|
92
|
+
/** A seat's outline in the given shape; `undefined` means the default `'seat'`. */
|
|
93
|
+
export declare function seatShapePath(shape: KerusiSeatShape | undefined, x: number, y: number, width: number, height: number): string;
|
|
94
|
+
/**
|
|
95
|
+
* Where the wheelchair marker's centre sits, as fractions of the box it is
|
|
96
|
+
* drawn on. The stock corner, (0.82, 0.18), overhangs a circle, so the circle
|
|
97
|
+
* pulls it in along the diagonal; every other preset keeps the stock corner. A
|
|
98
|
+
* function shape gets the stock corner too, so it should leave that corner
|
|
99
|
+
* filled.
|
|
100
|
+
*/
|
|
101
|
+
export declare function seatMarkerAnchor(shape: KerusiSeatShape | undefined): {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
};
|
|
72
105
|
//# sourceMappingURL=seat-shapes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-shapes.d.ts","sourceRoot":"","sources":["../../src/render/seat-shapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA4DH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,SAAI,GACR,MAAM,CAgBR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvE;AA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;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAC,CAAC;AAKpG,mFAAmF;AACnF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,CAeR;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAE7F"}
|
|
@@ -158,4 +158,51 @@ export function seatOccupantPath(x, y, width, height) {
|
|
|
158
158
|
export function seatOccupantStroke(width, height) {
|
|
159
159
|
return Math.min(width, height) * OCCUPANT_STROKE;
|
|
160
160
|
}
|
|
161
|
+
/** The `'rounded'` preset's corner radius, as a fraction of the short edge. */
|
|
162
|
+
const ROUNDED_RADIUS = 0.25;
|
|
163
|
+
/** A seat's outline in the given shape; `undefined` means the default `'seat'`. */
|
|
164
|
+
export function seatShapePath(shape, x, y, width, height) {
|
|
165
|
+
if (typeof shape === 'function') {
|
|
166
|
+
return shape({ x, y, width, height });
|
|
167
|
+
}
|
|
168
|
+
const edge = Math.min(width, height);
|
|
169
|
+
switch (shape) {
|
|
170
|
+
case 'square':
|
|
171
|
+
return roundedRect(x, y, width, height, edge * FRONT_RADIUS);
|
|
172
|
+
case 'rounded':
|
|
173
|
+
return roundedRect(x, y, width, height, edge * ROUNDED_RADIUS);
|
|
174
|
+
case 'circle':
|
|
175
|
+
return ellipse(x, y, width, height);
|
|
176
|
+
default:
|
|
177
|
+
return seatBodyPath(x, y, width, height);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Where the wheelchair marker's centre sits, as fractions of the box it is
|
|
182
|
+
* drawn on. The stock corner, (0.82, 0.18), overhangs a circle, so the circle
|
|
183
|
+
* pulls it in along the diagonal; every other preset keeps the stock corner. A
|
|
184
|
+
* function shape gets the stock corner too, so it should leave that corner
|
|
185
|
+
* filled.
|
|
186
|
+
*/
|
|
187
|
+
export function seatMarkerAnchor(shape) {
|
|
188
|
+
return shape === 'circle' ? { x: 0.75, y: 0.25 } : { x: 0.82, y: 0.18 };
|
|
189
|
+
}
|
|
190
|
+
function roundedRect(x, y, width, height, radius) {
|
|
191
|
+
const points = [
|
|
192
|
+
[x, y],
|
|
193
|
+
[x + width, y],
|
|
194
|
+
[x + width, y + height],
|
|
195
|
+
[x, y + height],
|
|
196
|
+
];
|
|
197
|
+
return roundedPolygon(points, [radius, radius, radius, radius]);
|
|
198
|
+
}
|
|
199
|
+
/** An ellipse filling the box: two half arcs, since a circle cannot be a subpath. */
|
|
200
|
+
function ellipse(x, y, width, height) {
|
|
201
|
+
const rx = r(width / 2);
|
|
202
|
+
const ry = r(height / 2);
|
|
203
|
+
const cy = r(y + height / 2);
|
|
204
|
+
return (`M ${r(x)} ${cy} ` +
|
|
205
|
+
`A ${rx} ${ry} 0 1 1 ${r(x + width)} ${cy} ` +
|
|
206
|
+
`A ${rx} ${ry} 0 1 1 ${r(x)} ${cy} Z`);
|
|
207
|
+
}
|
|
161
208
|
//# sourceMappingURL=seat-shapes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-shapes.js","sourceRoot":"","sources":["../../src/render/seat-shapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH,SAAS,CAAC,CAAC,KAAa;IACtB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;AACzC,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,gFAAgF;AAChF,MAAM,YAAY,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C,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG;QAC5C,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CACtC,CAAC;AACJ,CAAC"}
|
package/dist/view/index.d.ts
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* A binding turns these into markup; none of them know how.
|
|
8
8
|
*/
|
|
9
9
|
export * from './control-strings.js';
|
|
10
|
+
export * from './kerusi-seat-style.js';
|
|
10
11
|
export * from './kerusi-seatmap-colors.js';
|
|
11
12
|
export * from './rtl.js';
|
|
13
|
+
export * from './seat-glyph.js';
|
|
12
14
|
export * from './seat-aria.js';
|
|
13
15
|
export * from './selection.js';
|
|
14
16
|
export * from './viewport.js';
|
package/dist/view/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
package/dist/view/index.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* A binding turns these into markup; none of them know how.
|
|
8
8
|
*/
|
|
9
9
|
export * from './control-strings.js';
|
|
10
|
+
export * from './kerusi-seat-style.js';
|
|
10
11
|
export * from './kerusi-seatmap-colors.js';
|
|
11
12
|
export * from './rtl.js';
|
|
13
|
+
export * from './seat-glyph.js';
|
|
12
14
|
export * from './seat-aria.js';
|
|
13
15
|
export * from './selection.js';
|
|
14
16
|
export * from './viewport.js';
|
package/dist/view/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RenderSeat } from '../render/render-model.js';
|
|
2
|
+
import { KerusiSeatShape } from '../render/seat-shapes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Per-seat styling from code: the TypeScript counterpart of the
|
|
5
|
+
* `--kerusi-seat-fill` / `--kerusi-seat-label` tokens, for when the decision
|
|
6
|
+
* lives in the application (a recommendation, a search result, the document's
|
|
7
|
+
* own `Seat.metadata`) rather than in a stylesheet.
|
|
8
|
+
*
|
|
9
|
+
* A style is an *identity* colour, exactly like `SeatType.color`, and it takes
|
|
10
|
+
* the same slot. It never replaces the selected or blocked treatment, and a held
|
|
11
|
+
* or booked seat keeps its wash and occupant figure over it, so status is still
|
|
12
|
+
* read from shape (decision D4 in #26). A future `states` field is where a
|
|
13
|
+
* per-status override would go, if a real need for one appears.
|
|
14
|
+
*/
|
|
15
|
+
export interface KerusiSeatStyle {
|
|
16
|
+
/**
|
|
17
|
+
* The seat's own colour, in place of its `SeatType.color` or `availableBg`.
|
|
18
|
+
* Never applied to a selected or blocked seat. Any CSS colour works; a
|
|
19
|
+
* stylesheet's `--kerusi-seat-fill` still wins over it.
|
|
20
|
+
*/
|
|
21
|
+
fill?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The number's colour on that fill. When omitted, a hex `fill` gets black or
|
|
24
|
+
* white, whichever reads better; any other `fill` (a `var()`, `hsl()`) falls
|
|
25
|
+
* back to `availableFg`, so set this alongside it.
|
|
26
|
+
*/
|
|
27
|
+
labelColor?: string;
|
|
28
|
+
/** Extra classes on the seat's `<g>`, for CSS that needs more than colour. */
|
|
29
|
+
className?: string | readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* The seat's outline, in place of the default tapered `'seat'`. The wash, the
|
|
32
|
+
* selected frame and core, and the focus outline follow it. Only `'seat'`
|
|
33
|
+
* shows which way a seat faces.
|
|
34
|
+
*/
|
|
35
|
+
shape?: KerusiSeatShape;
|
|
36
|
+
}
|
|
37
|
+
/** Styles keyed by `SeatType.id`, for the `seatTypeStyles` input/prop. */
|
|
38
|
+
export type SeatTypeStyles = Readonly<Record<string, KerusiSeatStyle>>;
|
|
39
|
+
/**
|
|
40
|
+
* The `seatStyle` input/prop: a style for one seat, or nothing to leave it be.
|
|
41
|
+
* Called for every seat whenever the selection, state or theme changes.
|
|
42
|
+
*/
|
|
43
|
+
export type SeatStyleFn = (seat: RenderSeat, ctx: {
|
|
44
|
+
selected: boolean;
|
|
45
|
+
}) => KerusiSeatStyle | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The style a seat is drawn with: its type's entry in `typeStyles`, with the
|
|
48
|
+
* per-seat `fn` result laid over it field by field. Classes from both are kept.
|
|
49
|
+
* `undefined` when neither has anything to say.
|
|
50
|
+
*
|
|
51
|
+
* `typeStyles` applies whether or not `typeColors` is on: that flag governs the
|
|
52
|
+
* document's own `SeatType.color`, while a type style is the application's
|
|
53
|
+
* explicit choice.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveSeatStyle(seat: RenderSeat, selected: boolean, typeStyles?: SeatTypeStyles, fn?: SeatStyleFn): KerusiSeatStyle | undefined;
|
|
56
|
+
/** A `className` as a flat list of non-empty class names. */
|
|
57
|
+
export declare function classList(className: string | readonly string[] | undefined): string[];
|
|
58
|
+
//# sourceMappingURL=kerusi-seat-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kerusi-seat-style.d.ts","sourceRoot":"","sources":["../../src/view/kerusi-seat-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,KACvB,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,EACjB,UAAU,CAAC,EAAE,cAAc,EAC3B,EAAE,CAAC,EAAE,WAAW,GACf,eAAe,GAAG,SAAS,CAa7B;AAED,6DAA6D;AAC7D,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,CAMrF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The style a seat is drawn with: its type's entry in `typeStyles`, with the
|
|
3
|
+
* per-seat `fn` result laid over it field by field. Classes from both are kept.
|
|
4
|
+
* `undefined` when neither has anything to say.
|
|
5
|
+
*
|
|
6
|
+
* `typeStyles` applies whether or not `typeColors` is on: that flag governs the
|
|
7
|
+
* document's own `SeatType.color`, while a type style is the application's
|
|
8
|
+
* explicit choice.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveSeatStyle(seat, selected, typeStyles, fn) {
|
|
11
|
+
const byType = typeStyles?.[seat.type.id];
|
|
12
|
+
const bySeat = fn?.(seat, { selected }) ?? undefined;
|
|
13
|
+
if (!byType && !bySeat) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const classes = [...classList(byType?.className), ...classList(bySeat?.className)];
|
|
17
|
+
return {
|
|
18
|
+
fill: bySeat?.fill ?? byType?.fill,
|
|
19
|
+
labelColor: bySeat?.labelColor ?? byType?.labelColor,
|
|
20
|
+
shape: bySeat?.shape ?? byType?.shape,
|
|
21
|
+
className: classes.length ? classes : undefined,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** A `className` as a flat list of non-empty class names. */
|
|
25
|
+
export function classList(className) {
|
|
26
|
+
if (!className) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const parts = typeof className === 'string' ? [className] : className;
|
|
30
|
+
return parts.flatMap((part) => part.split(/\s+/)).filter(Boolean);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=kerusi-seat-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kerusi-seat-style.js","sourceRoot":"","sources":["../../src/view/kerusi-seat-style.ts"],"names":[],"mappings":"AAkDA;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAgB,EAChB,QAAiB,EACjB,UAA2B,EAC3B,EAAgB;IAEhB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,SAAS,CAAC;IACrD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACnF,OAAO;QACL,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,IAAI;QAClC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,MAAM,EAAE,UAAU;QACpD,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,MAAM,EAAE,KAAK;QACrC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;KAChD,CAAC;AACJ,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,SAAS,CAAC,SAAiD;IACzE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RenderSeat } from '../render/render-model.js';
|
|
1
|
+
import { RenderLegendEntry, RenderSeat } from '../render/render-model.js';
|
|
2
|
+
import { KerusiSeatStyle } from './kerusi-seat-style.js';
|
|
2
3
|
/**
|
|
3
4
|
* Theming for `<kerusi-seatmap>`.
|
|
4
5
|
*
|
|
@@ -93,15 +94,38 @@ export declare function resolveColors(colors?: KerusiSeatmapColors): Required<Ke
|
|
|
93
94
|
*
|
|
94
95
|
* `SeatType.color` deliberately does not go through here. That is the
|
|
95
96
|
* document's own value under §4.7, not the theme's, and {@link readableOn}
|
|
96
|
-
* still has to be able to parse it.
|
|
97
|
+
* still has to be able to parse it. It can only be overridden per seat, through
|
|
98
|
+
* {@link SEAT_FILL_VAR}, never by a global token.
|
|
97
99
|
*/
|
|
98
100
|
export declare function cssVar(key: keyof KerusiSeatmapColors, value: string): string;
|
|
99
101
|
/** `selectedBg` → `--kerusi-selected-bg`. */
|
|
100
102
|
export declare function cssVarName(key: keyof KerusiSeatmapColors): string;
|
|
103
|
+
/**
|
|
104
|
+
* The per-seat fill token. Unlike the `--kerusi-*` theme tokens above, this one
|
|
105
|
+
* is meant to be set on *some* seats, from a selector that picks them out:
|
|
106
|
+
*
|
|
107
|
+
* ```css
|
|
108
|
+
* .kerusi-seat[data-seat-type="vip"] { --kerusi-seat-fill: #d4a017; }
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* Custom properties inherit, so setting it on the seat's `<g>` reaches the body
|
|
112
|
+
* inside it. It replaces only the seat's own colour (the slot `SeatType.color`
|
|
113
|
+
* fills), never the selected or blocked treatment, so status stays readable.
|
|
114
|
+
* The library never sets it, and there is deliberately no global default: a
|
|
115
|
+
* document's type colour is overridden one targeted selector at a time.
|
|
116
|
+
*/
|
|
117
|
+
export declare const SEAT_FILL_VAR = "--kerusi-seat-fill";
|
|
118
|
+
/** The label colour that pairs with {@link SEAT_FILL_VAR}, set the same way. */
|
|
119
|
+
export declare const SEAT_LABEL_VAR = "--kerusi-seat-label";
|
|
101
120
|
/**
|
|
102
121
|
* The fill for a seat's body, in precedence order:
|
|
103
122
|
*
|
|
104
|
-
* selected → blocked → `
|
|
123
|
+
* selected → blocked → `--kerusi-seat-fill` → `style.fill` → `SeatType.color`
|
|
124
|
+
* → available
|
|
125
|
+
*
|
|
126
|
+
* `style` is the seat's resolved `seatStyle` / `seatTypeStyles` entry (see
|
|
127
|
+
* `resolveSeatStyle`). Like the CSS token it only fills the seat's own-colour
|
|
128
|
+
* slot, so it can never hide the selected or blocked treatment.
|
|
105
129
|
*
|
|
106
130
|
* For a selected seat this is the *frame*: {@link seatCoreFill}'s core is drawn
|
|
107
131
|
* inside it and covers most of the body, so `selectedBg` reads as a border
|
|
@@ -116,7 +140,7 @@ export declare function cssVarName(key: keyof KerusiSeatmapColors): string;
|
|
|
116
140
|
* whole signal, same as before. Attributes never affect the fill — §4.3.3
|
|
117
141
|
* makes them descriptive tags, not a rendering category.
|
|
118
142
|
*/
|
|
119
|
-
export declare function seatFill(seat: RenderSeat, selected: boolean, colors: Required<KerusiSeatmapColors>, useTypeColors: boolean): string;
|
|
143
|
+
export declare function seatFill(seat: RenderSeat, selected: boolean, colors: Required<KerusiSeatmapColors>, useTypeColors: boolean, style?: KerusiSeatStyle): string;
|
|
120
144
|
/**
|
|
121
145
|
* The bright core inside a selected seat's frame — the second of the two tones
|
|
122
146
|
* selection is drawn from, see the module doc comment. Everything drawn over
|
|
@@ -129,7 +153,17 @@ export declare function seatCoreFill(colors: Required<KerusiSeatmapColors>): str
|
|
|
129
153
|
* where the label sits on {@link seatCoreFill}'s core rather than on the frame,
|
|
130
154
|
* so the two tones swap round.
|
|
131
155
|
*/
|
|
132
|
-
export declare function seatTextFill(seat: RenderSeat, selected: boolean, colors: Required<KerusiSeatmapColors>, useTypeColors: boolean): string;
|
|
156
|
+
export declare function seatTextFill(seat: RenderSeat, selected: boolean, colors: Required<KerusiSeatmapColors>, useTypeColors: boolean, style?: KerusiSeatStyle): string;
|
|
157
|
+
/**
|
|
158
|
+
* A legend type swatch's fill: the same per-seat token and the same fallback as
|
|
159
|
+
* an available seat of that type, so a rule that sets `--kerusi-seat-fill` on
|
|
160
|
+
* `.kerusi-legend__item[data-seat-type="…"]` as well as on the seats keeps the
|
|
161
|
+
* key in step with the map. Pass the type's `seatTypeStyles` entry for the same
|
|
162
|
+
* reason; a per-seat `seatStyle` has no single value a legend could show.
|
|
163
|
+
*/
|
|
164
|
+
export declare function legendSwatchFill(entry: RenderLegendEntry, colors: Required<KerusiSeatmapColors>, useTypeColors: boolean, typeStyle?: KerusiSeatStyle): string;
|
|
165
|
+
/** The text colour that pairs with {@link legendSwatchFill}. */
|
|
166
|
+
export declare function legendSwatchText(entry: RenderLegendEntry, colors: Required<KerusiSeatmapColors>, useTypeColors: boolean, typeStyle?: KerusiSeatStyle): string;
|
|
133
167
|
/** Which occupant figure marks a seat, if any — see {@link seatFill}. */
|
|
134
168
|
export type SeatOccupantVariant = 'selected' | 'held' | 'booked';
|
|
135
169
|
/**
|
|
@@ -173,4 +207,6 @@ export declare function elementTextFill(tone: 'neutral' | 'accent' | 'muted', co
|
|
|
173
207
|
* the contrast each actually needs.
|
|
174
208
|
*/
|
|
175
209
|
export declare function readableOn(background: string): string;
|
|
210
|
+
/** Whether {@link readableOn} can read this colour: `#rgb` or `#rrggbb`. */
|
|
211
|
+
export declare function isHexColor(color: string): boolean;
|
|
176
212
|
//# sourceMappingURL=kerusi-seatmap-colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kerusi-seatmap-colors.d.ts","sourceRoot":"","sources":["../../src/view/kerusi-seatmap-colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"kerusi-seatmap-colors.d.ts","sourceRoot":"","sources":["../../src/view/kerusi-seatmap-colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,mBAAmB,CAmB/D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E,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
|
@@ -46,7 +46,8 @@ export function resolveColors(colors) {
|
|
|
46
46
|
*
|
|
47
47
|
* `SeatType.color` deliberately does not go through here. That is the
|
|
48
48
|
* document's own value under §4.7, not the theme's, and {@link readableOn}
|
|
49
|
-
* still has to be able to parse it.
|
|
49
|
+
* still has to be able to parse it. It can only be overridden per seat, through
|
|
50
|
+
* {@link SEAT_FILL_VAR}, never by a global token.
|
|
50
51
|
*/
|
|
51
52
|
export function cssVar(key, value) {
|
|
52
53
|
return `var(${cssVarName(key)}, ${value})`;
|
|
@@ -55,10 +56,32 @@ export function cssVar(key, value) {
|
|
|
55
56
|
export function cssVarName(key) {
|
|
56
57
|
return `--kerusi-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`;
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* The per-seat fill token. Unlike the `--kerusi-*` theme tokens above, this one
|
|
61
|
+
* is meant to be set on *some* seats, from a selector that picks them out:
|
|
62
|
+
*
|
|
63
|
+
* ```css
|
|
64
|
+
* .kerusi-seat[data-seat-type="vip"] { --kerusi-seat-fill: #d4a017; }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* Custom properties inherit, so setting it on the seat's `<g>` reaches the body
|
|
68
|
+
* inside it. It replaces only the seat's own colour (the slot `SeatType.color`
|
|
69
|
+
* fills), never the selected or blocked treatment, so status stays readable.
|
|
70
|
+
* The library never sets it, and there is deliberately no global default: a
|
|
71
|
+
* document's type colour is overridden one targeted selector at a time.
|
|
72
|
+
*/
|
|
73
|
+
export const SEAT_FILL_VAR = '--kerusi-seat-fill';
|
|
74
|
+
/** The label colour that pairs with {@link SEAT_FILL_VAR}, set the same way. */
|
|
75
|
+
export const SEAT_LABEL_VAR = '--kerusi-seat-label';
|
|
58
76
|
/**
|
|
59
77
|
* The fill for a seat's body, in precedence order:
|
|
60
78
|
*
|
|
61
|
-
* selected → blocked → `
|
|
79
|
+
* selected → blocked → `--kerusi-seat-fill` → `style.fill` → `SeatType.color`
|
|
80
|
+
* → available
|
|
81
|
+
*
|
|
82
|
+
* `style` is the seat's resolved `seatStyle` / `seatTypeStyles` entry (see
|
|
83
|
+
* `resolveSeatStyle`). Like the CSS token it only fills the seat's own-colour
|
|
84
|
+
* slot, so it can never hide the selected or blocked treatment.
|
|
62
85
|
*
|
|
63
86
|
* For a selected seat this is the *frame*: {@link seatCoreFill}'s core is drawn
|
|
64
87
|
* inside it and covers most of the body, so `selectedBg` reads as a border
|
|
@@ -73,14 +96,34 @@ export function cssVarName(key) {
|
|
|
73
96
|
* whole signal, same as before. Attributes never affect the fill — §4.3.3
|
|
74
97
|
* makes them descriptive tags, not a rendering category.
|
|
75
98
|
*/
|
|
76
|
-
export function seatFill(seat, selected, colors, useTypeColors) {
|
|
99
|
+
export function seatFill(seat, selected, colors, useTypeColors, style) {
|
|
77
100
|
if (selected) {
|
|
78
101
|
return cssVar('selectedBg', colors.selectedBg);
|
|
79
102
|
}
|
|
80
103
|
if (seat.status === 'blocked') {
|
|
81
104
|
return cssVar('blockedBg', colors.blockedBg);
|
|
82
105
|
}
|
|
83
|
-
return (
|
|
106
|
+
return `var(${SEAT_FILL_VAR}, ${baseFill(seat.typeColor, colors, useTypeColors, style)})`;
|
|
107
|
+
}
|
|
108
|
+
/** A seat's own colour: its type's, when allowed, or the theme's available fill. */
|
|
109
|
+
function baseFill(typeColor, colors, useTypeColors, style) {
|
|
110
|
+
return style?.fill || (useTypeColors && typeColor) || cssVar('availableBg', colors.availableBg);
|
|
111
|
+
}
|
|
112
|
+
/** The label colour to pair with {@link baseFill}. */
|
|
113
|
+
function baseText(typeColor, colors, useTypeColors, style) {
|
|
114
|
+
if (style?.labelColor) {
|
|
115
|
+
return style.labelColor;
|
|
116
|
+
}
|
|
117
|
+
if (style?.fill) {
|
|
118
|
+
// Only a hex colour can be read for contrast; for anything else the theme's
|
|
119
|
+
// label colour is the safer guess, and the docs say to set `labelColor`.
|
|
120
|
+
return isHexColor(style.fill)
|
|
121
|
+
? readableOn(style.fill)
|
|
122
|
+
: cssVar('availableFg', colors.availableFg);
|
|
123
|
+
}
|
|
124
|
+
return useTypeColors && typeColor
|
|
125
|
+
? readableOn(typeColor)
|
|
126
|
+
: cssVar('availableFg', colors.availableFg);
|
|
84
127
|
}
|
|
85
128
|
/**
|
|
86
129
|
* The bright core inside a selected seat's frame — the second of the two tones
|
|
@@ -96,16 +139,28 @@ export function seatCoreFill(colors) {
|
|
|
96
139
|
* where the label sits on {@link seatCoreFill}'s core rather than on the frame,
|
|
97
140
|
* so the two tones swap round.
|
|
98
141
|
*/
|
|
99
|
-
export function seatTextFill(seat, selected, colors, useTypeColors) {
|
|
142
|
+
export function seatTextFill(seat, selected, colors, useTypeColors, style) {
|
|
100
143
|
if (selected) {
|
|
101
144
|
return cssVar('selectedBg', colors.selectedBg);
|
|
102
145
|
}
|
|
103
146
|
if (seat.status === 'blocked') {
|
|
104
147
|
return cssVar('blockedFg', colors.blockedFg);
|
|
105
148
|
}
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
149
|
+
return `var(${SEAT_LABEL_VAR}, ${baseText(seat.typeColor, colors, useTypeColors, style)})`;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A legend type swatch's fill: the same per-seat token and the same fallback as
|
|
153
|
+
* an available seat of that type, so a rule that sets `--kerusi-seat-fill` on
|
|
154
|
+
* `.kerusi-legend__item[data-seat-type="…"]` as well as on the seats keeps the
|
|
155
|
+
* key in step with the map. Pass the type's `seatTypeStyles` entry for the same
|
|
156
|
+
* reason; a per-seat `seatStyle` has no single value a legend could show.
|
|
157
|
+
*/
|
|
158
|
+
export function legendSwatchFill(entry, colors, useTypeColors, typeStyle) {
|
|
159
|
+
return `var(${SEAT_FILL_VAR}, ${baseFill(entry.color, colors, useTypeColors, typeStyle)})`;
|
|
160
|
+
}
|
|
161
|
+
/** The text colour that pairs with {@link legendSwatchFill}. */
|
|
162
|
+
export function legendSwatchText(entry, colors, useTypeColors, typeStyle) {
|
|
163
|
+
return `var(${SEAT_LABEL_VAR}, ${baseText(entry.color, colors, useTypeColors, typeStyle)})`;
|
|
109
164
|
}
|
|
110
165
|
/**
|
|
111
166
|
* The occupant figure for a seat, or `null` for a seat with nothing to draw:
|
|
@@ -194,6 +249,10 @@ export function readableOn(background) {
|
|
|
194
249
|
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
195
250
|
return luminance > 0.179 ? '#000000' : '#ffffff';
|
|
196
251
|
}
|
|
252
|
+
/** Whether {@link readableOn} can read this colour: `#rgb` or `#rrggbb`. */
|
|
253
|
+
export function isHexColor(color) {
|
|
254
|
+
return parseHex(color) !== undefined;
|
|
255
|
+
}
|
|
197
256
|
/** `#rgb` or `#rrggbb` to channel values. Returns `undefined` for anything else. */
|
|
198
257
|
function parseHex(color) {
|
|
199
258
|
const hex = color.trim().replace(/^#/, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kerusi-seatmap-colors.js","sourceRoot":"","sources":["../../src/view/kerusi-seatmap-colors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kerusi-seatmap-colors.js","sourceRoot":"","sources":["../../src/view/kerusi-seatmap-colors.ts"],"names":[],"mappings":"AAyEA,MAAM,CAAC,MAAM,qBAAqB,GAAkC;IAClE,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,SAAS;IACrB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,eAAe,EAAE,SAAS;IAC1B,eAAe,EAAE,SAAS;IAC1B,cAAc,EAA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CAAC,CAAC,GAAG;aACA,KAAK,CAAC,EAAE,CAAC;aACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;aACjB,IAAI,CAAC,EAAE,CAAC;QACb,CAAC,CAAC,GAAG,CAAC;IACV,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { RenderSeat } from '../render/render-model.js';
|
|
2
|
+
import { SeatBox } from '../render/seat-shapes.js';
|
|
3
|
+
import { PlacedSeat } from '../render/section-layout.js';
|
|
4
|
+
import { KerusiSeatStyle } from './kerusi-seat-style.js';
|
|
5
|
+
import { KerusiSeatmapColors, SeatOccupantVariant } from './kerusi-seatmap-colors.js';
|
|
6
|
+
/**
|
|
7
|
+
* The seat glyph, resolved: every path, paint and position a binding draws
|
|
8
|
+
* inside one seat's `<g>`.
|
|
9
|
+
*
|
|
10
|
+
* Both bindings used to call the paint and shape functions one by one, and each
|
|
11
|
+
* kept its own copy of the "mark box" rule below. That is exactly the code the
|
|
12
|
+
* architecture says belongs in core, so it lives here now and a binding only
|
|
13
|
+
* binds the result. It is also what a custom seat template receives, so a
|
|
14
|
+
* consumer drawing their own seat can reuse the library's paths and colours
|
|
15
|
+
* rather than re-derive them.
|
|
16
|
+
*/
|
|
17
|
+
/** A filled path. */
|
|
18
|
+
export interface SeatGlyphShape {
|
|
19
|
+
/** The path's `d` attribute. */
|
|
20
|
+
d: string;
|
|
21
|
+
/** A CSS paint, usually a `var(--kerusi-*, …)` with the resolved fallback. */
|
|
22
|
+
fill: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SeatGlyph {
|
|
25
|
+
/** `null` for an available or blocked seat: nothing to mark. */
|
|
26
|
+
variant: SeatOccupantVariant | null;
|
|
27
|
+
/** The classes for the seat's `<g>`: `kerusi-seat`, its status, and the modifiers. */
|
|
28
|
+
className: string;
|
|
29
|
+
/**
|
|
30
|
+
* The `data-*` attributes for the seat's `<g>`, so CSS can pick seats out by
|
|
31
|
+
* what the document says about them. An absent field is not rendered.
|
|
32
|
+
*/
|
|
33
|
+
data: SeatDataAttributes;
|
|
34
|
+
/** The seat's own placed box. */
|
|
35
|
+
box: SeatBox;
|
|
36
|
+
/**
|
|
37
|
+
* The box the decorative marks sit on: the seat's own, or the selected core's
|
|
38
|
+
* when it is selected. See {@link resolveSeatGlyph}.
|
|
39
|
+
*/
|
|
40
|
+
markBox: SeatBox;
|
|
41
|
+
/**
|
|
42
|
+
* The outline: by default square-ish at the front and tapered at the back, so
|
|
43
|
+
* facing reads from the shape; otherwise the seat style's `shape`.
|
|
44
|
+
*/
|
|
45
|
+
body: SeatGlyphShape;
|
|
46
|
+
/** The dimming wash over a held or booked seat; absent otherwise. */
|
|
47
|
+
wash?: SeatGlyphShape;
|
|
48
|
+
/** The bright plate inside a selected seat's frame; absent otherwise. */
|
|
49
|
+
core?: SeatGlyphShape;
|
|
50
|
+
/** The occupant figure for a selected, held or booked seat; absent otherwise. */
|
|
51
|
+
occupant?: SeatGlyphShape & {
|
|
52
|
+
variant: SeatOccupantVariant;
|
|
53
|
+
/** `none` except for the hollow held figure. */
|
|
54
|
+
stroke: string;
|
|
55
|
+
strokeWidth: number;
|
|
56
|
+
};
|
|
57
|
+
/** The seat number, centred on the seat and kept upright. */
|
|
58
|
+
label: {
|
|
59
|
+
text: string;
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
fontSize: number;
|
|
63
|
+
fill: string;
|
|
64
|
+
/** A core-coloured halo behind a selected seat's number; `none` otherwise. */
|
|
65
|
+
halo: string;
|
|
66
|
+
haloWidth: number;
|
|
67
|
+
/** Cancels the seat's rotation; `null` when the seat does not rotate. */
|
|
68
|
+
transform: string | null;
|
|
69
|
+
};
|
|
70
|
+
/** The corner marker for `accessibility.wheelchairAccessible`; absent otherwise. */
|
|
71
|
+
wheelchair?: {
|
|
72
|
+
cx: number;
|
|
73
|
+
cy: number;
|
|
74
|
+
r: number;
|
|
75
|
+
fill: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** See {@link SeatGlyph.data}. Each field is bound as the attribute named beside it. */
|
|
79
|
+
export interface SeatDataAttributes {
|
|
80
|
+
/** `data-seat-type`: `Seat.type`. */
|
|
81
|
+
type: string;
|
|
82
|
+
/** `data-seat-status`: the merged availability, same as the status class. */
|
|
83
|
+
status: string;
|
|
84
|
+
/** `data-section-id`: the section the seat belongs to. */
|
|
85
|
+
section: string;
|
|
86
|
+
/** `data-seat-row`: `Seat.row`, when the seat names one. */
|
|
87
|
+
row?: string;
|
|
88
|
+
/**
|
|
89
|
+
* `data-seat-attributes`: `Seat.attributes`, space-separated, when there are
|
|
90
|
+
* any, so `[data-seat-attributes~="aisle"]` matches one tag among several.
|
|
91
|
+
*/
|
|
92
|
+
attributes?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* What a custom seat template is handed: the seat, whether it is selected, and
|
|
96
|
+
* the stock glyph already resolved for it. Each binding extends this with a
|
|
97
|
+
* framework-native way to draw the stock glyph (`defaultContent`).
|
|
98
|
+
*/
|
|
99
|
+
export interface KerusiSeatContext {
|
|
100
|
+
/** The seat as placed in its section, in viewBox units. */
|
|
101
|
+
placed: PlacedSeat;
|
|
102
|
+
/** The resolved seat: status, type, price, accessibility, `source.metadata`. */
|
|
103
|
+
seat: RenderSeat;
|
|
104
|
+
/** Whether the seat is in the current selection. */
|
|
105
|
+
selected: boolean;
|
|
106
|
+
/** The stock glyph's paths and paints, for reuse. */
|
|
107
|
+
glyph: SeatGlyph;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolves the stock glyph for one placed seat.
|
|
111
|
+
*
|
|
112
|
+
* Everything over a selected seat sits on its core, so every mark is measured
|
|
113
|
+
* from the core's box rather than the seat's. Drawing to the seat's box leaves
|
|
114
|
+
* the occupant's hips crossing the frame, where a figure tinted `selectedBg`
|
|
115
|
+
* lands on a frame filled `selectedBg` and reads as a hard nub. Because the core
|
|
116
|
+
* is an exact scaled copy of the body (see `seatSelectedFrame`), measuring from
|
|
117
|
+
* it keeps every clearance a mark had against the body, so the frame width stays
|
|
118
|
+
* free to change. *
|
|
119
|
+
* `style` is the seat's resolved `seatStyle` / `seatTypeStyles` entry (see
|
|
120
|
+
* `resolveSeatStyle`). It changes the seat's own colour, label colour and
|
|
121
|
+
* classes; it never changes a selected or blocked seat's fill.
|
|
122
|
+
*/
|
|
123
|
+
export declare function resolveSeatGlyph(placed: PlacedSeat, selected: boolean, colors: Required<KerusiSeatmapColors>, typeColors: boolean, style?: KerusiSeatStyle): SeatGlyph;
|
|
124
|
+
/**
|
|
125
|
+
* The outline for a legend type swatch drawn in its type's `shape`, on a
|
|
126
|
+
* `size`-square box, or `undefined` to keep the flat square swatch: a type with
|
|
127
|
+
* no shape, or the default `'seat'`, has nothing a square does not already say.
|
|
128
|
+
*/
|
|
129
|
+
export declare function legendSwatchPath(typeStyle: KerusiSeatStyle | undefined, size: number): string | undefined;
|
|
130
|
+
/** The `data-*` attributes for a seat's `<g>`; see {@link SeatDataAttributes}. */
|
|
131
|
+
export declare function seatDataAttributes(seat: RenderSeat): SeatDataAttributes;
|
|
132
|
+
/**
|
|
133
|
+
* The class list for a seat's `<g>`: the hooks the READMEs document, then any
|
|
134
|
+
* `extra` classes from the seat's style.
|
|
135
|
+
*/
|
|
136
|
+
export declare function seatClassName(seat: RenderSeat, selected: boolean, extra?: string | readonly string[]): string;
|
|
137
|
+
//# sourceMappingURL=seat-glyph.d.ts.map
|
|
@@ -0,0 +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,6BAA6B,CAAC;AACzD,OAAO,EAAa,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,mBAAmB,EAGnB,mBAAmB,EAMpB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;GAUG;AAEH,qBAAqB;AACrB,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,gEAAgE;IAChE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACpC,sFAAsF;IACtF,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,EAAE,kBAAkB,CAAC;IACzB,iCAAiC;IACjC,GAAG,EAAE,OAAO,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,IAAI,EAAE,cAAc,CAAC;IACrB,qEAAqE;IACrE,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,yEAAyE;IACzE,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,cAAc,GAAG;QAC1B,OAAO,EAAE,mBAAmB,CAAC;QAC7B,gDAAgD;QAChD,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,6DAA6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AgB,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"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { seatMarkerAnchor, seatOccupantPath, seatOccupantStroke, seatSelectedFrame, seatShapePath, } from '../render/seat-shapes.js';
|
|
2
|
+
import { classList } from './kerusi-seat-style.js';
|
|
3
|
+
import { occupantFillFor, occupantStrokeFor, seatCoreFill, seatFill, seatOccupantVariant, seatTextFill, seatWashFill, } from './kerusi-seatmap-colors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the stock glyph for one placed seat.
|
|
6
|
+
*
|
|
7
|
+
* Everything over a selected seat sits on its core, so every mark is measured
|
|
8
|
+
* from the core's box rather than the seat's. Drawing to the seat's box leaves
|
|
9
|
+
* the occupant's hips crossing the frame, where a figure tinted `selectedBg`
|
|
10
|
+
* lands on a frame filled `selectedBg` and reads as a hard nub. Because the core
|
|
11
|
+
* is an exact scaled copy of the body (see `seatSelectedFrame`), measuring from
|
|
12
|
+
* it keeps every clearance a mark had against the body, so the frame width stays
|
|
13
|
+
* free to change. *
|
|
14
|
+
* `style` is the seat's resolved `seatStyle` / `seatTypeStyles` entry (see
|
|
15
|
+
* `resolveSeatStyle`). It changes the seat's own colour, label colour and
|
|
16
|
+
* classes; it never changes a selected or blocked seat's fill.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveSeatGlyph(placed, selected, colors, typeColors, style) {
|
|
19
|
+
const seat = placed.seat;
|
|
20
|
+
const variant = seatOccupantVariant(seat, selected);
|
|
21
|
+
const box = {
|
|
22
|
+
x: placed.x,
|
|
23
|
+
y: placed.y,
|
|
24
|
+
width: placed.width,
|
|
25
|
+
height: placed.height,
|
|
26
|
+
};
|
|
27
|
+
const markBox = selected ? coreBox(box) : box;
|
|
28
|
+
const shape = style?.shape;
|
|
29
|
+
const bodyD = seatShapePath(shape, box.x, box.y, box.width, box.height);
|
|
30
|
+
const anchor = seatMarkerAnchor(shape);
|
|
31
|
+
const textFill = seatTextFill(seat, selected, colors, typeColors, style);
|
|
32
|
+
return {
|
|
33
|
+
variant,
|
|
34
|
+
className: seatClassName(seat, selected, style?.className),
|
|
35
|
+
data: seatDataAttributes(seat),
|
|
36
|
+
box,
|
|
37
|
+
markBox,
|
|
38
|
+
body: { d: bodyD, fill: seatFill(seat, selected, colors, typeColors, style) },
|
|
39
|
+
wash: variant === 'held' || variant === 'booked'
|
|
40
|
+
? { d: bodyD, fill: seatWashFill(variant, colors) }
|
|
41
|
+
: undefined,
|
|
42
|
+
core: selected
|
|
43
|
+
? {
|
|
44
|
+
d: seatShapePath(shape, markBox.x, markBox.y, markBox.width, markBox.height),
|
|
45
|
+
fill: seatCoreFill(colors),
|
|
46
|
+
}
|
|
47
|
+
: undefined,
|
|
48
|
+
occupant: variant
|
|
49
|
+
? {
|
|
50
|
+
variant,
|
|
51
|
+
d: seatOccupantPath(markBox.x, markBox.y, markBox.width, markBox.height),
|
|
52
|
+
fill: occupantFillFor(variant, colors),
|
|
53
|
+
stroke: occupantStrokeFor(variant, colors),
|
|
54
|
+
strokeWidth: seatOccupantStroke(markBox.width, markBox.height),
|
|
55
|
+
}
|
|
56
|
+
: undefined,
|
|
57
|
+
label: {
|
|
58
|
+
text: seat.label,
|
|
59
|
+
x: placed.centerX,
|
|
60
|
+
y: placed.centerY,
|
|
61
|
+
fontSize: placed.fontSize,
|
|
62
|
+
fill: textFill,
|
|
63
|
+
// The label is centred on the occupant's shoulder line, so without the
|
|
64
|
+
// halo a selected seat's number is `selectedBg` over a `selectedBg`
|
|
65
|
+
// silhouette. It also rescues a label too long for the core.
|
|
66
|
+
halo: selected ? seatCoreFill(colors) : 'none',
|
|
67
|
+
haloWidth: selected ? placed.fontSize * 0.22 : 0,
|
|
68
|
+
transform: placed.rotation
|
|
69
|
+
? `rotate(${-placed.rotation} ${placed.centerX} ${placed.centerY})`
|
|
70
|
+
: null,
|
|
71
|
+
},
|
|
72
|
+
// The marker keeps the same relative corner on whichever box it sits on, so
|
|
73
|
+
// a selected seat's dot stays whole instead of being bitten off by the frame.
|
|
74
|
+
wheelchair: seat.accessibility?.wheelchairAccessible
|
|
75
|
+
? {
|
|
76
|
+
cx: markBox.x + markBox.width * anchor.x,
|
|
77
|
+
cy: markBox.y + markBox.height * anchor.y,
|
|
78
|
+
r: markBox.width * 0.13,
|
|
79
|
+
fill: textFill,
|
|
80
|
+
}
|
|
81
|
+
: undefined,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The outline for a legend type swatch drawn in its type's `shape`, on a
|
|
86
|
+
* `size`-square box, or `undefined` to keep the flat square swatch: a type with
|
|
87
|
+
* no shape, or the default `'seat'`, has nothing a square does not already say.
|
|
88
|
+
*/
|
|
89
|
+
export function legendSwatchPath(typeStyle, size) {
|
|
90
|
+
const shape = typeStyle?.shape;
|
|
91
|
+
return shape && shape !== 'seat' ? seatShapePath(shape, 0, 0, size, size) : undefined;
|
|
92
|
+
}
|
|
93
|
+
/** The selected core's box: the seat's, inset by the frame width on every side. */
|
|
94
|
+
function coreBox(box) {
|
|
95
|
+
const frame = seatSelectedFrame(box.width, box.height);
|
|
96
|
+
return {
|
|
97
|
+
x: box.x + frame,
|
|
98
|
+
y: box.y + frame,
|
|
99
|
+
width: box.width - frame * 2,
|
|
100
|
+
height: box.height - frame * 2,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** The `data-*` attributes for a seat's `<g>`; see {@link SeatDataAttributes}. */
|
|
104
|
+
export function seatDataAttributes(seat) {
|
|
105
|
+
return {
|
|
106
|
+
type: seat.type.id,
|
|
107
|
+
status: seat.status,
|
|
108
|
+
section: seat.sectionId,
|
|
109
|
+
row: seat.row || undefined,
|
|
110
|
+
attributes: seat.attributes.length ? seat.attributes.join(' ') : undefined,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The class list for a seat's `<g>`: the hooks the READMEs document, then any
|
|
115
|
+
* `extra` classes from the seat's style.
|
|
116
|
+
*/
|
|
117
|
+
export function seatClassName(seat, selected, extra) {
|
|
118
|
+
return [
|
|
119
|
+
'kerusi-seat',
|
|
120
|
+
`kerusi-seat--${seat.status}`,
|
|
121
|
+
selected ? 'kerusi-seat--selected' : '',
|
|
122
|
+
seat.selectable ? '' : 'kerusi-seat--unselectable',
|
|
123
|
+
seat.accessibility?.wheelchairAccessible ? 'kerusi-seat--wheelchair' : '',
|
|
124
|
+
seat.companions.length > 0 ? 'kerusi-seat--companion' : '',
|
|
125
|
+
...classList(extra),
|
|
126
|
+
]
|
|
127
|
+
.filter(Boolean)
|
|
128
|
+
.join(' ');
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=seat-glyph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seat-glyph.js","sourceRoot":"","sources":["../../src/view/seat-glyph.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAmB,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAEL,eAAe,EACf,iBAAiB,EAEjB,YAAY,EACZ,QAAQ,EACR,mBAAmB,EACnB,YAAY,EACZ,YAAY,GACb,MAAM,4BAA4B,CAAC;AAyGpC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAkB,EAClB,QAAiB,EACjB,MAAqC,EACrC,UAAmB,E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AAC,IAAI,CAAC,EAAE;QAClB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,SAAS;QACvB,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,SAAS;QAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;KAC3E,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAgB,EAChB,QAAiB,EACjB,KAAkC;IAElC,OAAO;QACL,aAAa;QACb,gBAAgB,IAAI,CAAC,MAAM,EAAE;QAC7B,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE;QACvC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,2BAA2B;QAClD,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE;QACzE,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE;QAC1D,GAAG,SAAS,CAAC,KAAK,CAAC;KACpB;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerusiweb/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
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
5
|
"keywords": [
|
|
6
6
|
"kerusi",
|