@seanyeh77/ui 0.48.3 → 0.49.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/bundle.js +2 -2
- package/dist/components/FloorPlan/FloorPlan.d.ts +65 -0
- package/dist/components/FloorPlan/FloorPlan.js +822 -0
- package/dist/components/FloorPlan/FloorPlan.js.map +1 -0
- package/dist/components/ZoneMap/ZoneMap.d.ts +3 -0
- package/dist/components/ZoneMap/ZoneMap.js +6 -20
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
- package/dist/css/FloorPlan.css +270 -0
- package/dist/css/ZoneMap.css +0 -97
- package/dist/css/base.css +99 -0
- package/dist/i18n.js +6 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/zone.js +48 -0
- package/dist/internal/zone.js.map +1 -0
- package/dist/styles.css +364 -97
- package/docs/DataColors.md +1 -1
- package/docs/FloorPlan.md +43 -0
- package/docs/ZoneMap.md +2 -2
- package/docs/agents.md +5 -5
- package/docs/components.json +4 -0
- package/docs/data.md +2 -1
- package/docs/monitoring.md +7 -1
- package/package.json +2 -2
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { devWarn } from "../../internal/dev.js";
|
|
3
|
+
import { cx, reduced, resizeObserver, useMedia, useNarrow } from "../../internal/util.js";
|
|
4
|
+
import { heatRange, noData, zoneText } from "../../internal/zone.js";
|
|
5
|
+
import { format } from "../../format.js";
|
|
6
|
+
import { tr } from "../../i18n.js";
|
|
7
|
+
import corners_out_default from "../../icons/ph/corners-out.js";
|
|
8
|
+
import minus_default from "../../icons/ph/minus.js";
|
|
9
|
+
import plus_default from "../../icons/ph/plus.js";
|
|
10
|
+
import { includeIcons } from "../../icons/store.js";
|
|
11
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
// src/components/FloorPlan/FloorPlan.tsx
|
|
15
|
+
includeIcons(plus_default, minus_default, corners_out_default);
|
|
16
|
+
/** One ring as SVG path data, y flipped (north up on screen). */
|
|
17
|
+
function ringPath(ring) {
|
|
18
|
+
return ring.length ? "M" + ring.map(([x, y]) => fmt(x) + " " + fmt(-y)).join("L") + "Z" : "";
|
|
19
|
+
}
|
|
20
|
+
const fmt = (n) => String(Math.round(n * 1e3) / 1e3);
|
|
21
|
+
/** A MultiPolygon as one SVG path; drawn with fill-rule evenodd, inner rings are holes. */
|
|
22
|
+
function polygonPath(mp) {
|
|
23
|
+
return mp.map((poly) => poly.map(ringPath).join("")).join("");
|
|
24
|
+
}
|
|
25
|
+
/** The viewBox (in flipped coordinates: y down) holding every zone and the shell, with a margin of 4 % of the longer
|
|
26
|
+
* side on each edge. */
|
|
27
|
+
function planBox(shapes) {
|
|
28
|
+
let [x0, y0, x1, y1] = [
|
|
29
|
+
Infinity,
|
|
30
|
+
Infinity,
|
|
31
|
+
-Infinity,
|
|
32
|
+
-Infinity
|
|
33
|
+
];
|
|
34
|
+
for (const mp of shapes) for (const poly of mp) for (const ring of poly) for (const [x, y] of ring) {
|
|
35
|
+
x0 = Math.min(x0, x);
|
|
36
|
+
x1 = Math.max(x1, x);
|
|
37
|
+
y0 = Math.min(y0, -y);
|
|
38
|
+
y1 = Math.max(y1, -y);
|
|
39
|
+
}
|
|
40
|
+
if (!Number.isFinite(x0)) return {
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
w: 1,
|
|
44
|
+
h: 1
|
|
45
|
+
};
|
|
46
|
+
const w = Math.max(x1 - x0, 1e-6);
|
|
47
|
+
const h = Math.max(y1 - y0, 1e-6);
|
|
48
|
+
const m = Math.max(w, h) * .04;
|
|
49
|
+
return {
|
|
50
|
+
x: x0 - m,
|
|
51
|
+
y: y0 - m,
|
|
52
|
+
w: w + 2 * m,
|
|
53
|
+
h: h + 2 * m
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The area in m²: outlines minus holes. */
|
|
57
|
+
function polygonArea(mp) {
|
|
58
|
+
let total = 0;
|
|
59
|
+
for (const poly of mp) poly.forEach((ring, i) => {
|
|
60
|
+
let a = 0;
|
|
61
|
+
for (let k = 0; k < ring.length; k++) {
|
|
62
|
+
const [xa, ya] = ring[k];
|
|
63
|
+
const [xb, yb] = ring[(k + 1) % ring.length];
|
|
64
|
+
a += xa * yb - xb * ya;
|
|
65
|
+
}
|
|
66
|
+
total += (i === 0 ? 1 : -1) * Math.abs(a / 2);
|
|
67
|
+
});
|
|
68
|
+
return total;
|
|
69
|
+
}
|
|
70
|
+
/** Whether [x, y] (metres, y up) is inside, by the even-odd rule over every ring. */
|
|
71
|
+
function insidePolygon(x, y, mp) {
|
|
72
|
+
let inside = false;
|
|
73
|
+
for (const poly of mp) for (const ring of poly) for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
|
|
74
|
+
const [xi, yi] = ring[i];
|
|
75
|
+
const [xj, yj] = ring[j];
|
|
76
|
+
if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) inside = !inside;
|
|
77
|
+
}
|
|
78
|
+
return inside;
|
|
79
|
+
}
|
|
80
|
+
function bounds(mp) {
|
|
81
|
+
return planBox([mp]);
|
|
82
|
+
}
|
|
83
|
+
/** Primary zones first, then muted ones; each from the smallest area up. The Tab order, and the order labels are
|
|
84
|
+
* given room in. */
|
|
85
|
+
function zoneOrder(zones) {
|
|
86
|
+
const area = new Map(zones.map((z) => [z, polygonArea(z.outline)]));
|
|
87
|
+
return [...zones].sort((a, b) => Number(a.emphasis === "muted") - Number(b.emphasis === "muted") || (area.get(a) ?? 0) - (area.get(b) ?? 0));
|
|
88
|
+
}
|
|
89
|
+
/** The screen transform for a viewBox shown in W × H px (preserveAspectRatio xMidYMid meet): px per metre, and the
|
|
90
|
+
* screen point of a point in metres (y up). */
|
|
91
|
+
function screenOf(view, W, H) {
|
|
92
|
+
const s = Math.min(W / view.w, H / view.h);
|
|
93
|
+
const ox = (W - view.w * s) / 2 - view.x * s;
|
|
94
|
+
const oy = (H - view.h * s) / 2 - view.y * s;
|
|
95
|
+
return {
|
|
96
|
+
s,
|
|
97
|
+
at: (x, y) => [x * s + ox, -y * s + oy],
|
|
98
|
+
back: (px, py) => [(px - ox) / s, -(py - oy) / s]
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Width in px of text at a font size: a fixed estimate (CJK 1 em, Geist Mono 0.6 em, other Latin 0.58 em), so
|
|
102
|
+
* labels are laid out the same before and after web fonts load, on the server and in tests. */
|
|
103
|
+
function textWidth(text, size, mono = false) {
|
|
104
|
+
let w = 0;
|
|
105
|
+
for (const ch of text) {
|
|
106
|
+
const c = ch.codePointAt(0) ?? 0;
|
|
107
|
+
w += c >= 11904 ? 1 : ch === " " || ch === "\xA0" ? .3 : mono ? .6 : /[A-Z0-9]/.test(ch) ? .64 : .54;
|
|
108
|
+
}
|
|
109
|
+
return Math.ceil(w * size);
|
|
110
|
+
}
|
|
111
|
+
/** Places labels in the given order (zoneOrder): the full label where it fits inside the zone's outline and clear of
|
|
112
|
+
* labels already placed, else the one-line pill where it is clear, else none (the zone still shows its tooltip).
|
|
113
|
+
* Slender zones (bounding box over 4 : 1) get the pill only. `taken` holds boxes already in use (group names). */
|
|
114
|
+
function placeLabels(items, view, W, H, taken = []) {
|
|
115
|
+
const { at, back } = screenOf(view, W, H);
|
|
116
|
+
const out = /* @__PURE__ */ new Map();
|
|
117
|
+
const used = [...taken];
|
|
118
|
+
const clear = (b) => b.x >= 0 && b.y >= 0 && b.x + b.w <= W && b.y + b.h <= H && used.every((u) => b.x + b.w + 2 <= u.x || u.x + u.w + 2 <= b.x || b.y + b.h + 2 <= u.y || u.y + u.h + 2 <= b.y);
|
|
119
|
+
for (const it of items) {
|
|
120
|
+
const [cx, cy] = at(it.label[0], it.label[1]);
|
|
121
|
+
const box = ([w, h]) => ({
|
|
122
|
+
x: cx - w / 2,
|
|
123
|
+
y: cy - h / 2,
|
|
124
|
+
w,
|
|
125
|
+
h
|
|
126
|
+
});
|
|
127
|
+
let spot = {
|
|
128
|
+
kind: null,
|
|
129
|
+
x: cx,
|
|
130
|
+
y: cy,
|
|
131
|
+
w: 0,
|
|
132
|
+
h: 0
|
|
133
|
+
};
|
|
134
|
+
if (!it.slender) {
|
|
135
|
+
const b = box(it.full);
|
|
136
|
+
if ([
|
|
137
|
+
[b.x, b.y],
|
|
138
|
+
[b.x + b.w, b.y],
|
|
139
|
+
[b.x, b.y + b.h],
|
|
140
|
+
[b.x + b.w, b.y + b.h],
|
|
141
|
+
[cx, b.y],
|
|
142
|
+
[cx, b.y + b.h],
|
|
143
|
+
[b.x, cy],
|
|
144
|
+
[b.x + b.w, cy]
|
|
145
|
+
].every(([px, py]) => insidePolygon(...back(px, py), it.outline)) && clear(b)) spot = {
|
|
146
|
+
kind: "full",
|
|
147
|
+
...b
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (!spot.kind) {
|
|
151
|
+
const b = box(it.pill);
|
|
152
|
+
if (clear(b)) spot = {
|
|
153
|
+
kind: "pill",
|
|
154
|
+
...b
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (spot.kind) used.push(spot);
|
|
158
|
+
out.set(it.id, spot);
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
const MIN_H = 240;
|
|
163
|
+
const MAX_H = 640;
|
|
164
|
+
const MAX_ZOOM = 8;
|
|
165
|
+
/** A floor plan of zones with any outline (L shapes, pieces, holes), each filled by its value on the heat scale with
|
|
166
|
+
* its name, figure and state. Zones are buttons in Tab order (primary first, smaller first); Enter or Space selects.
|
|
167
|
+
* Wheel, pinch, drag, + − and the arrow keys zoom and pan; 「重設視角」 shows the whole plan again. */
|
|
168
|
+
function FloorPlan({ zones, label, groups = [], shell, edges = [], legend = true, fill = false, className, ...p }) {
|
|
169
|
+
const id = "fp" + React.useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
170
|
+
const ids = React.useMemo(() => new Map(zones.map((z) => [z.id, z])), [zones]);
|
|
171
|
+
devWarn(ids.size !== zones.length, "FloorPlan", "two zones share an id: give each zone its own id, value and onChange use it.");
|
|
172
|
+
devWarn(() => edges.some((e) => !ids.has(e.a) || !ids.has(e.b)), "FloorPlan", () => `an edge names a zone that is not in zones (${edges.filter((e) => !ids.has(e.a) || !ids.has(e.b)).map((e) => e.a + "–" + e.b).join(", ")}).`);
|
|
173
|
+
devWarn(() => zones.some((z) => !insidePolygon(z.label[0], z.label[1], z.outline)), "FloorPlan", () => `the label point of ${zones.filter((z) => !insidePolygon(z.label[0], z.label[1], z.outline)).map((z) => z.id).join(", ")} is outside its outline: pass a point inside (e.g. the pole of inaccessibility).`);
|
|
174
|
+
const [min, max] = heatRange(zones, p.min, p.max);
|
|
175
|
+
const base = React.useMemo(() => planBox([...zones.map((z) => z.outline), ...shell ? [shell] : []]), [zones, shell]);
|
|
176
|
+
const order = React.useMemo(() => zoneOrder(zones), [zones]);
|
|
177
|
+
const paths = React.useMemo(() => new Map(zones.map((z) => [z.id, polygonPath(z.outline)])), [zones]);
|
|
178
|
+
const box = React.useRef(null);
|
|
179
|
+
const [size, setSize] = React.useState(() => [800, Math.max(MIN_H, Math.min(MAX_H, 800 * base.h / base.w))]);
|
|
180
|
+
React.useLayoutEffect(() => {
|
|
181
|
+
const el = box.current;
|
|
182
|
+
if (!el) return;
|
|
183
|
+
const measure = () => {
|
|
184
|
+
const r = el.getBoundingClientRect();
|
|
185
|
+
if (r.width > 0 && r.height > 0) setSize((s) => Math.abs(s[0] - r.width) < .5 && Math.abs(s[1] - r.height) < .5 ? s : [r.width, r.height]);
|
|
186
|
+
};
|
|
187
|
+
measure();
|
|
188
|
+
const ro = resizeObserver(measure);
|
|
189
|
+
ro?.observe(el);
|
|
190
|
+
return () => ro?.disconnect();
|
|
191
|
+
}, []);
|
|
192
|
+
const [W, H] = size;
|
|
193
|
+
const baseKey = `${base.x},${base.y},${base.w},${base.h}`;
|
|
194
|
+
const [viewState, setViewState] = React.useState({
|
|
195
|
+
key: baseKey,
|
|
196
|
+
view: base
|
|
197
|
+
});
|
|
198
|
+
const view = viewState.key === baseKey ? viewState.view : base;
|
|
199
|
+
const setView = React.useCallback((v) => setViewState({
|
|
200
|
+
key: baseKey,
|
|
201
|
+
view: v
|
|
202
|
+
}), [baseKey]);
|
|
203
|
+
const clampView = React.useCallback((v) => {
|
|
204
|
+
if (v.w >= base.w * .999) return base;
|
|
205
|
+
const w = Math.max(base.w / MAX_ZOOM, v.w);
|
|
206
|
+
const h = w * base.h / base.w;
|
|
207
|
+
const cx = Math.min(base.x + base.w, Math.max(base.x, v.x + v.w / 2));
|
|
208
|
+
const cy = Math.min(base.y + base.h, Math.max(base.y, v.y + v.h / 2));
|
|
209
|
+
return {
|
|
210
|
+
x: cx - w / 2,
|
|
211
|
+
y: cy - h / 2,
|
|
212
|
+
w,
|
|
213
|
+
h
|
|
214
|
+
};
|
|
215
|
+
}, [base]);
|
|
216
|
+
const viewRef = React.useRef(view);
|
|
217
|
+
React.useLayoutEffect(() => {
|
|
218
|
+
viewRef.current = view;
|
|
219
|
+
});
|
|
220
|
+
const anim = React.useRef(0);
|
|
221
|
+
const goTo = React.useCallback((to, animate) => {
|
|
222
|
+
cancelAnimationFrame(anim.current);
|
|
223
|
+
const target = clampView(to);
|
|
224
|
+
if (!animate || reduced() || typeof requestAnimationFrame !== "function") return setView(target);
|
|
225
|
+
const from = viewRef.current;
|
|
226
|
+
const t0 = performance.now();
|
|
227
|
+
const step = (now) => {
|
|
228
|
+
const t = Math.min(1, (now - t0) / 200);
|
|
229
|
+
const e = 1 - (1 - t) ** 3;
|
|
230
|
+
if (t >= 1) return setView(target);
|
|
231
|
+
setView({
|
|
232
|
+
x: from.x + (target.x - from.x) * e,
|
|
233
|
+
y: from.y + (target.y - from.y) * e,
|
|
234
|
+
w: from.w + (target.w - from.w) * e,
|
|
235
|
+
h: from.h + (target.h - from.h) * e
|
|
236
|
+
});
|
|
237
|
+
anim.current = requestAnimationFrame(step);
|
|
238
|
+
};
|
|
239
|
+
anim.current = requestAnimationFrame(step);
|
|
240
|
+
}, [clampView, setView]);
|
|
241
|
+
React.useEffect(() => () => cancelAnimationFrame(anim.current), []);
|
|
242
|
+
/** Zoom by factor around a screen point (px in the drawing); default its middle. */
|
|
243
|
+
const zoomAt = React.useCallback((factor, px = W / 2, py = H / 2, animate = false) => {
|
|
244
|
+
const v = viewRef.current;
|
|
245
|
+
const { back } = screenOf(v, W, H);
|
|
246
|
+
const [mx, my] = back(px, py);
|
|
247
|
+
const fy = -my;
|
|
248
|
+
const w = v.w / factor;
|
|
249
|
+
const h = v.h / factor;
|
|
250
|
+
goTo({
|
|
251
|
+
x: mx - (mx - v.x) / v.w * w,
|
|
252
|
+
y: fy - (fy - v.y) / v.h * h,
|
|
253
|
+
w,
|
|
254
|
+
h
|
|
255
|
+
}, animate);
|
|
256
|
+
}, [
|
|
257
|
+
W,
|
|
258
|
+
H,
|
|
259
|
+
goTo
|
|
260
|
+
]);
|
|
261
|
+
const zoomed = Math.abs(view.w - base.w) > base.w * .001 || Math.abs(view.x - base.x) > base.w * .001 || Math.abs(view.y - base.y) > base.h * .001;
|
|
262
|
+
const svg = React.useRef(null);
|
|
263
|
+
React.useEffect(() => {
|
|
264
|
+
const el = svg.current;
|
|
265
|
+
if (!el) return;
|
|
266
|
+
const onWheel = (e) => {
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
const r = el.getBoundingClientRect();
|
|
269
|
+
zoomAt(Math.exp(-e.deltaY * (e.deltaMode === 1 ? .05 : .0015)), e.clientX - r.left, e.clientY - r.top);
|
|
270
|
+
};
|
|
271
|
+
el.addEventListener("wheel", onWheel, { passive: false });
|
|
272
|
+
return () => el.removeEventListener("wheel", onWheel);
|
|
273
|
+
}, [zoomAt]);
|
|
274
|
+
const pointers = React.useRef(/* @__PURE__ */ new Map());
|
|
275
|
+
const gesture = React.useRef({
|
|
276
|
+
moved: false,
|
|
277
|
+
start: [0, 0]
|
|
278
|
+
});
|
|
279
|
+
const local = (e) => {
|
|
280
|
+
const r = svg.current?.getBoundingClientRect();
|
|
281
|
+
return r ? [e.clientX - r.left, e.clientY - r.top] : [0, 0];
|
|
282
|
+
};
|
|
283
|
+
const onPointerDown = (e) => {
|
|
284
|
+
if (e.button !== 0) return;
|
|
285
|
+
pointers.current.set(e.pointerId, local(e));
|
|
286
|
+
if (pointers.current.size === 1) gesture.current = {
|
|
287
|
+
moved: false,
|
|
288
|
+
start: local(e)
|
|
289
|
+
};
|
|
290
|
+
else gesture.current.dist = void 0;
|
|
291
|
+
};
|
|
292
|
+
const onPointerMove = (e) => {
|
|
293
|
+
const prev = pointers.current.get(e.pointerId);
|
|
294
|
+
if (!prev) return;
|
|
295
|
+
const now = local(e);
|
|
296
|
+
const g = gesture.current;
|
|
297
|
+
if (!g.moved && Math.hypot(now[0] - g.start[0], now[1] - g.start[1]) > 4) {
|
|
298
|
+
g.moved = true;
|
|
299
|
+
if (typeof svg.current?.setPointerCapture === "function") for (const pid of pointers.current.keys()) svg.current.setPointerCapture(pid);
|
|
300
|
+
}
|
|
301
|
+
if (!g.moved) {
|
|
302
|
+
pointers.current.set(e.pointerId, now);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const v = viewRef.current;
|
|
306
|
+
const s = Math.min(W / v.w, H / v.h);
|
|
307
|
+
if (pointers.current.size === 1) goTo({
|
|
308
|
+
...v,
|
|
309
|
+
x: v.x - (now[0] - prev[0]) / s,
|
|
310
|
+
y: v.y - (now[1] - prev[1]) / s
|
|
311
|
+
}, false);
|
|
312
|
+
pointers.current.set(e.pointerId, now);
|
|
313
|
+
if (pointers.current.size === 2) {
|
|
314
|
+
const [a, b] = [...pointers.current.values()];
|
|
315
|
+
const d = Math.hypot(a[0] - b[0], a[1] - b[1]);
|
|
316
|
+
if (g.dist) zoomAt(d / g.dist, (a[0] + b[0]) / 2, (a[1] + b[1]) / 2);
|
|
317
|
+
g.dist = d;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const onPointerUp = (e) => {
|
|
321
|
+
pointers.current.delete(e.pointerId);
|
|
322
|
+
if (pointers.current.size < 2) gesture.current.dist = void 0;
|
|
323
|
+
};
|
|
324
|
+
const pick = (z) => {
|
|
325
|
+
if (gesture.current.moved) return;
|
|
326
|
+
p.onChange?.(z.id, z);
|
|
327
|
+
};
|
|
328
|
+
const onKeyDown = (e) => {
|
|
329
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
330
|
+
const v = viewRef.current;
|
|
331
|
+
const pan = {
|
|
332
|
+
ArrowLeft: [-1, 0],
|
|
333
|
+
ArrowRight: [1, 0],
|
|
334
|
+
ArrowUp: [0, -1],
|
|
335
|
+
ArrowDown: [0, 1]
|
|
336
|
+
};
|
|
337
|
+
if (e.key === "+" || e.key === "=") zoomAt(1.5, void 0, void 0, true);
|
|
338
|
+
else if (e.key === "-" || e.key === "_") zoomAt(1 / 1.5, void 0, void 0, true);
|
|
339
|
+
else if (pan[e.key]) goTo({
|
|
340
|
+
...v,
|
|
341
|
+
x: v.x + pan[e.key][0] * v.w * .15,
|
|
342
|
+
y: v.y + pan[e.key][1] * v.h * .15
|
|
343
|
+
}, true);
|
|
344
|
+
else return;
|
|
345
|
+
e.preventDefault();
|
|
346
|
+
};
|
|
347
|
+
const [tip, setTip] = React.useState(null);
|
|
348
|
+
const [focused, setFocused] = React.useState(null);
|
|
349
|
+
const [focusRing, setFocusRing] = React.useState(null);
|
|
350
|
+
const narrow = useNarrow();
|
|
351
|
+
const coarse = useMedia("(pointer: coarse)");
|
|
352
|
+
const scr = screenOf(view, W, H);
|
|
353
|
+
const s = scr.s;
|
|
354
|
+
const texts = new Map(zones.map((z) => [z.id, zoneText(z, min, max, z.emphasis === "muted" ? [tr("次要")] : [])]));
|
|
355
|
+
const textOf = (z) => texts.get(z.id) ?? zoneText(z, min, max);
|
|
356
|
+
const groupBoxes = [];
|
|
357
|
+
for (const g of groups) {
|
|
358
|
+
const members = zones.filter((z) => z.group === g.id);
|
|
359
|
+
if (members.length) groupBoxes.push({
|
|
360
|
+
g,
|
|
361
|
+
members,
|
|
362
|
+
b: planBox(members.map((m) => m.outline))
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
const groupLabels = groupBoxes.map(({ g, b }) => {
|
|
366
|
+
const m = Math.max(b.w, b.h) / 1.08 * .04;
|
|
367
|
+
const [x, y] = scr.at(b.x + m, -(b.y + m));
|
|
368
|
+
const w = textWidth(g.name, 13) + 12;
|
|
369
|
+
return {
|
|
370
|
+
g,
|
|
371
|
+
box: {
|
|
372
|
+
x: Math.max(0, Math.min(W - w, x)),
|
|
373
|
+
y: Math.max(0, y - 26),
|
|
374
|
+
w,
|
|
375
|
+
h: 22
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
});
|
|
379
|
+
const spots = placeLabels(order.map((z) => {
|
|
380
|
+
const t = textOf(z);
|
|
381
|
+
const muted = z.emphasis === "muted" || noData(z);
|
|
382
|
+
const warn = !!z.tone && z.tone !== "normal";
|
|
383
|
+
const bb = bounds(z.outline);
|
|
384
|
+
const ratio = Math.max(bb.w, bb.h) / Math.max(1e-9, Math.min(bb.w, bb.h));
|
|
385
|
+
const unitW = z.unit ? textWidth("\xA0" + z.unit, muted ? 13 : 16) : 0;
|
|
386
|
+
const head = noData(z) ? tr("沒有資料") : t.state;
|
|
387
|
+
const full = muted ? [Math.max(textWidth((warn ? "⚠ " : "") + z.name, 13), textWidth(noData(z) ? head : t.figure, 16, !noData(z)) + unitW) + 12, 46] : [Math.max(textWidth(z.name, 16), textWidth(t.figure, 25, true) + unitW, textWidth(head, 13)) + 16, 80];
|
|
388
|
+
const pill = [textWidth((warn ? "⚠ " : "") + z.name + " ", 13) + (noData(z) ? textWidth(tr("沒有資料"), 13) : textWidth(t.figure, 13, true) + (z.unit ? textWidth("\xA0" + z.unit, 13) : 0)) + 18, 24];
|
|
389
|
+
return {
|
|
390
|
+
id: z.id,
|
|
391
|
+
outline: z.outline,
|
|
392
|
+
label: z.label,
|
|
393
|
+
muted,
|
|
394
|
+
slender: ratio > 4,
|
|
395
|
+
full,
|
|
396
|
+
pill
|
|
397
|
+
};
|
|
398
|
+
}), view, W, H, groupLabels.map((l) => l.box));
|
|
399
|
+
const u = (px) => px / s;
|
|
400
|
+
const all = {
|
|
401
|
+
x: view.x - view.w,
|
|
402
|
+
y: view.y - view.h,
|
|
403
|
+
w: view.w * 3,
|
|
404
|
+
h: view.h * 3
|
|
405
|
+
};
|
|
406
|
+
const selected = p.value != null ? ids.get(p.value) : void 0;
|
|
407
|
+
const ring = (zid, inner, width, color, key) => /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsxs("mask", {
|
|
408
|
+
id: `${id}-${key}`,
|
|
409
|
+
maskUnits: "userSpaceOnUse",
|
|
410
|
+
x: all.x,
|
|
411
|
+
y: all.y,
|
|
412
|
+
width: all.w,
|
|
413
|
+
height: all.h,
|
|
414
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
415
|
+
d: paths.get(zid),
|
|
416
|
+
fill: "#fff",
|
|
417
|
+
stroke: "#fff",
|
|
418
|
+
strokeWidth: u(2 * (inner + width)),
|
|
419
|
+
strokeLinejoin: "round",
|
|
420
|
+
fillRule: "evenodd"
|
|
421
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
422
|
+
d: paths.get(zid),
|
|
423
|
+
fill: "#000",
|
|
424
|
+
stroke: "#000",
|
|
425
|
+
strokeWidth: u(2 * inner),
|
|
426
|
+
strokeLinejoin: "round",
|
|
427
|
+
fillRule: "evenodd"
|
|
428
|
+
})]
|
|
429
|
+
}), /* @__PURE__ */ jsx("rect", {
|
|
430
|
+
x: all.x,
|
|
431
|
+
y: all.y,
|
|
432
|
+
width: all.w,
|
|
433
|
+
height: all.h,
|
|
434
|
+
style: { fill: color },
|
|
435
|
+
mask: `url(#${id}-${key})`,
|
|
436
|
+
pointerEvents: "none"
|
|
437
|
+
})] }, key);
|
|
438
|
+
const hasMuted = zones.some((z) => z.emphasis === "muted");
|
|
439
|
+
const unit = zones.find((z) => z.unit)?.unit;
|
|
440
|
+
const tipZone = tip ? ids.get(tip.id) : void 0;
|
|
441
|
+
const tipAt = tip ?? {
|
|
442
|
+
x: 0,
|
|
443
|
+
y: 0
|
|
444
|
+
};
|
|
445
|
+
const tipText = tipZone ? texts.get(tipZone.id) : void 0;
|
|
446
|
+
const hint = `${id}-hint`;
|
|
447
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
448
|
+
className: cx("ui-floorplan", fill && "is-fill", className),
|
|
449
|
+
role: "group",
|
|
450
|
+
"aria-label": label,
|
|
451
|
+
"aria-describedby": hint,
|
|
452
|
+
onKeyDown,
|
|
453
|
+
children: [
|
|
454
|
+
/* @__PURE__ */ jsx("span", {
|
|
455
|
+
id: hint,
|
|
456
|
+
className: "ui-visually-hidden",
|
|
457
|
+
children: tr("+ − 縮放,方向鍵平移")
|
|
458
|
+
}),
|
|
459
|
+
/* @__PURE__ */ jsxs("div", {
|
|
460
|
+
ref: box,
|
|
461
|
+
className: "ui-fp-box",
|
|
462
|
+
style: fill ? void 0 : { aspectRatio: `${base.w} / ${base.h}` },
|
|
463
|
+
onPointerLeave: () => setTip((t) => t && focused === t.id ? t : null),
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
466
|
+
ref: svg,
|
|
467
|
+
className: "ui-fp-svg",
|
|
468
|
+
viewBox: `${view.x} ${view.y} ${view.w} ${view.h}`,
|
|
469
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
470
|
+
onPointerDown,
|
|
471
|
+
onPointerMove,
|
|
472
|
+
onPointerUp,
|
|
473
|
+
onPointerCancel: onPointerUp,
|
|
474
|
+
children: [
|
|
475
|
+
/* @__PURE__ */ jsxs("defs", { children: [/* @__PURE__ */ jsx("pattern", {
|
|
476
|
+
id: `${id}-stripes`,
|
|
477
|
+
patternUnits: "userSpaceOnUse",
|
|
478
|
+
width: u(9),
|
|
479
|
+
height: u(9),
|
|
480
|
+
patternTransform: "rotate(45)",
|
|
481
|
+
children: /* @__PURE__ */ jsx("rect", {
|
|
482
|
+
width: u(4),
|
|
483
|
+
height: u(9),
|
|
484
|
+
className: "ui-fp-stripe"
|
|
485
|
+
})
|
|
486
|
+
}), zones.map((z) => z.tone && z.tone !== "normal" && !noData(z) ? /* @__PURE__ */ jsx("clipPath", {
|
|
487
|
+
id: `${id}-clip-${z.id}`,
|
|
488
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
489
|
+
d: paths.get(z.id),
|
|
490
|
+
clipRule: "evenodd"
|
|
491
|
+
})
|
|
492
|
+
}, z.id) : null)] }),
|
|
493
|
+
shell ? /* @__PURE__ */ jsx("path", {
|
|
494
|
+
className: "ui-fp-shell",
|
|
495
|
+
d: polygonPath(shell),
|
|
496
|
+
fillRule: "evenodd"
|
|
497
|
+
}) : null,
|
|
498
|
+
order.map((z) => {
|
|
499
|
+
const d = paths.get(z.id) ?? "";
|
|
500
|
+
if (noData(z)) return /* @__PURE__ */ jsx("path", {
|
|
501
|
+
className: "ui-fp-empty",
|
|
502
|
+
d,
|
|
503
|
+
fillRule: "evenodd"
|
|
504
|
+
}, z.id);
|
|
505
|
+
const t = textOf(z);
|
|
506
|
+
const muted = z.emphasis === "muted";
|
|
507
|
+
const on = p.value === z.id;
|
|
508
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
509
|
+
role: "button",
|
|
510
|
+
tabIndex: 0,
|
|
511
|
+
"aria-pressed": on,
|
|
512
|
+
"aria-label": t.label,
|
|
513
|
+
className: cx("ui-fp-zone", "is-" + t.tone, muted && "is-muted", on && "is-selected"),
|
|
514
|
+
"data-id": z.id,
|
|
515
|
+
onClick: () => pick(z),
|
|
516
|
+
onKeyDown: (e) => {
|
|
517
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
518
|
+
e.preventDefault();
|
|
519
|
+
p.onChange?.(z.id, z);
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
onPointerEnter: (e) => {
|
|
523
|
+
const r = box.current?.getBoundingClientRect();
|
|
524
|
+
if (r && e.pointerType === "mouse") setTip({
|
|
525
|
+
id: z.id,
|
|
526
|
+
x: e.clientX - r.left,
|
|
527
|
+
y: e.clientY - r.top
|
|
528
|
+
});
|
|
529
|
+
},
|
|
530
|
+
onPointerMove: (e) => {
|
|
531
|
+
const r = box.current?.getBoundingClientRect();
|
|
532
|
+
if (r && e.pointerType === "mouse" && pointers.current.size === 0) setTip({
|
|
533
|
+
id: z.id,
|
|
534
|
+
x: e.clientX - r.left,
|
|
535
|
+
y: e.clientY - r.top
|
|
536
|
+
});
|
|
537
|
+
},
|
|
538
|
+
onPointerLeave: () => setTip((v) => v?.id === z.id && focused !== z.id ? null : v),
|
|
539
|
+
onFocus: (e) => {
|
|
540
|
+
setFocused(z.id);
|
|
541
|
+
if (e.target.matches?.(":focus-visible")) {
|
|
542
|
+
setFocusRing(z.id);
|
|
543
|
+
const [x, y] = scr.at(z.label[0], z.label[1]);
|
|
544
|
+
setTip({
|
|
545
|
+
id: z.id,
|
|
546
|
+
x,
|
|
547
|
+
y
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
onBlur: () => {
|
|
552
|
+
setFocused(null);
|
|
553
|
+
setFocusRing(null);
|
|
554
|
+
setTip((v) => v?.id === z.id ? null : v);
|
|
555
|
+
},
|
|
556
|
+
children: [
|
|
557
|
+
/* @__PURE__ */ jsx("path", {
|
|
558
|
+
className: "ui-fp-fill",
|
|
559
|
+
d,
|
|
560
|
+
fillRule: "evenodd",
|
|
561
|
+
style: { fill: muted ? `color-mix(in srgb, ${t.bg} 40%, var(--surface))` : t.bg }
|
|
562
|
+
}),
|
|
563
|
+
z.forecast ? /* @__PURE__ */ jsx("path", {
|
|
564
|
+
d,
|
|
565
|
+
fillRule: "evenodd",
|
|
566
|
+
fill: `url(#${id}-stripes)`,
|
|
567
|
+
pointerEvents: "none"
|
|
568
|
+
}) : null,
|
|
569
|
+
t.tone !== "normal" ? /* @__PURE__ */ jsx("path", {
|
|
570
|
+
className: "ui-fp-tone",
|
|
571
|
+
d,
|
|
572
|
+
fill: "none",
|
|
573
|
+
strokeWidth: u(8),
|
|
574
|
+
clipPath: `url(#${id}-clip-${z.id})`,
|
|
575
|
+
pointerEvents: "none"
|
|
576
|
+
}) : null,
|
|
577
|
+
(narrow || coarse) && Math.min(bounds(z.outline).w, bounds(z.outline).h) / 1.08 * s < 48 ? /* @__PURE__ */ jsx("circle", {
|
|
578
|
+
cx: z.label[0],
|
|
579
|
+
cy: -z.label[1],
|
|
580
|
+
r: u(24),
|
|
581
|
+
fill: "transparent"
|
|
582
|
+
}) : null
|
|
583
|
+
]
|
|
584
|
+
}, z.id);
|
|
585
|
+
}),
|
|
586
|
+
edges.map((e, i) => e.segs.map((seg, k) => /* @__PURE__ */ jsx("polyline", {
|
|
587
|
+
className: "ui-fp-edge",
|
|
588
|
+
points: seg.map(([x, y]) => `${fmt(x)},${fmt(-y)}`).join(" "),
|
|
589
|
+
vectorEffect: "non-scaling-stroke"
|
|
590
|
+
}, i + "-" + k))),
|
|
591
|
+
groupBoxes.map(({ g, members }) => /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsxs("mask", {
|
|
592
|
+
id: `${id}-g-${g.id}`,
|
|
593
|
+
maskUnits: "userSpaceOnUse",
|
|
594
|
+
x: all.x,
|
|
595
|
+
y: all.y,
|
|
596
|
+
width: all.w,
|
|
597
|
+
height: all.h,
|
|
598
|
+
children: [members.map((m) => /* @__PURE__ */ jsx("path", {
|
|
599
|
+
d: paths.get(m.id),
|
|
600
|
+
fill: "#fff",
|
|
601
|
+
stroke: "#fff",
|
|
602
|
+
strokeWidth: u(7),
|
|
603
|
+
strokeLinejoin: "round",
|
|
604
|
+
fillRule: "evenodd"
|
|
605
|
+
}, m.id)), members.map((m) => /* @__PURE__ */ jsx("path", {
|
|
606
|
+
d: paths.get(m.id),
|
|
607
|
+
fill: "#000",
|
|
608
|
+
stroke: "#000",
|
|
609
|
+
strokeWidth: u(4),
|
|
610
|
+
strokeLinejoin: "round",
|
|
611
|
+
fillRule: "evenodd"
|
|
612
|
+
}, m.id))]
|
|
613
|
+
}), /* @__PURE__ */ jsx("rect", {
|
|
614
|
+
x: all.x,
|
|
615
|
+
y: all.y,
|
|
616
|
+
width: all.w,
|
|
617
|
+
height: all.h,
|
|
618
|
+
className: "ui-fp-group",
|
|
619
|
+
mask: `url(#${id}-g-${g.id})`
|
|
620
|
+
})] }, g.id)),
|
|
621
|
+
selected && !noData(selected) ? ring(selected.id, 4, 2, "var(--ink)", "sel") : null,
|
|
622
|
+
focusRing ? ring(focusRing, 1, 2, "var(--focus)", "focus") : null
|
|
623
|
+
]
|
|
624
|
+
}),
|
|
625
|
+
/* @__PURE__ */ jsxs("div", {
|
|
626
|
+
className: "ui-fp-labels",
|
|
627
|
+
"aria-hidden": "true",
|
|
628
|
+
children: [groupLabels.map(({ g, box: b }) => /* @__PURE__ */ jsx("span", {
|
|
629
|
+
className: "ui-fp-group-name",
|
|
630
|
+
style: {
|
|
631
|
+
left: b.x,
|
|
632
|
+
top: b.y,
|
|
633
|
+
width: b.w
|
|
634
|
+
},
|
|
635
|
+
children: g.name
|
|
636
|
+
}, g.id)), order.map((z) => {
|
|
637
|
+
const spot = spots.get(z.id);
|
|
638
|
+
if (!spot?.kind) return null;
|
|
639
|
+
const t = textOf(z);
|
|
640
|
+
const empty = noData(z);
|
|
641
|
+
const muted = z.emphasis === "muted" || empty;
|
|
642
|
+
const warn = t.tone !== "normal" && !empty;
|
|
643
|
+
const pos = {
|
|
644
|
+
left: spot.x,
|
|
645
|
+
top: spot.y,
|
|
646
|
+
width: spot.w,
|
|
647
|
+
height: spot.h
|
|
648
|
+
};
|
|
649
|
+
const unitEl = z.unit && !empty ? /* @__PURE__ */ jsx("span", {
|
|
650
|
+
className: "ui-fp-unit",
|
|
651
|
+
children: "\xA0" + z.unit
|
|
652
|
+
}) : null;
|
|
653
|
+
if (spot.kind === "pill") return /* @__PURE__ */ jsxs("span", {
|
|
654
|
+
className: cx("ui-fp-pill", empty && "is-empty"),
|
|
655
|
+
style: pos,
|
|
656
|
+
children: [
|
|
657
|
+
(warn ? "⚠ " : "") + z.name + " ",
|
|
658
|
+
/* @__PURE__ */ jsx("span", {
|
|
659
|
+
className: empty ? void 0 : "ui-fp-num",
|
|
660
|
+
children: empty ? tr("沒有資料") : t.figure
|
|
661
|
+
}),
|
|
662
|
+
unitEl
|
|
663
|
+
]
|
|
664
|
+
}, z.id);
|
|
665
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
666
|
+
className: cx("ui-fp-label", muted && "is-muted", empty && "is-empty"),
|
|
667
|
+
"data-fill": muted ? void 0 : t.fill,
|
|
668
|
+
style: {
|
|
669
|
+
...pos,
|
|
670
|
+
color: muted ? void 0 : t.color
|
|
671
|
+
},
|
|
672
|
+
children: [
|
|
673
|
+
/* @__PURE__ */ jsx("span", {
|
|
674
|
+
className: "ui-fp-name",
|
|
675
|
+
children: (muted && warn ? "⚠ " : "") + z.name
|
|
676
|
+
}),
|
|
677
|
+
empty ? /* @__PURE__ */ jsx("span", {
|
|
678
|
+
className: "ui-fp-state",
|
|
679
|
+
children: tr("沒有資料")
|
|
680
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
681
|
+
className: "ui-fp-value",
|
|
682
|
+
children: [t.figure, unitEl]
|
|
683
|
+
}),
|
|
684
|
+
muted ? null : /* @__PURE__ */ jsx("span", {
|
|
685
|
+
className: "ui-fp-state",
|
|
686
|
+
children: t.state
|
|
687
|
+
})
|
|
688
|
+
]
|
|
689
|
+
}, z.id);
|
|
690
|
+
})]
|
|
691
|
+
}),
|
|
692
|
+
tipZone && tipText ? /* @__PURE__ */ jsxs("div", {
|
|
693
|
+
className: "ui-fp-tip",
|
|
694
|
+
"aria-hidden": "true",
|
|
695
|
+
style: tipStyle(tipAt.x, tipAt.y, W, H),
|
|
696
|
+
children: [
|
|
697
|
+
/* @__PURE__ */ jsx("span", {
|
|
698
|
+
className: "ui-fp-tip-name",
|
|
699
|
+
children: tipZone.name
|
|
700
|
+
}),
|
|
701
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
702
|
+
/* @__PURE__ */ jsx("span", {
|
|
703
|
+
className: "ui-fp-num",
|
|
704
|
+
children: tipText.figure
|
|
705
|
+
}),
|
|
706
|
+
tipZone.unit ? "\xA0" + tipZone.unit : "",
|
|
707
|
+
tr(",") + tipText.state,
|
|
708
|
+
tipZone.emphasis === "muted" ? tr(",") + tr("次要") : ""
|
|
709
|
+
] }),
|
|
710
|
+
tipZone.detail ? /* @__PURE__ */ jsx("span", { children: tipZone.detail }) : null
|
|
711
|
+
]
|
|
712
|
+
}) : null,
|
|
713
|
+
/* @__PURE__ */ jsxs("div", {
|
|
714
|
+
className: "ui-fp-controls",
|
|
715
|
+
children: [
|
|
716
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
717
|
+
icon: "plus",
|
|
718
|
+
label: tr("放大"),
|
|
719
|
+
tooltip: false,
|
|
720
|
+
onClick: () => zoomAt(1.5, void 0, void 0, true),
|
|
721
|
+
disabled: view.w <= base.w / MAX_ZOOM + 1e-9
|
|
722
|
+
}),
|
|
723
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
724
|
+
icon: "minus",
|
|
725
|
+
label: tr("縮小"),
|
|
726
|
+
tooltip: false,
|
|
727
|
+
onClick: () => zoomAt(1 / 1.5, void 0, void 0, true),
|
|
728
|
+
disabled: !zoomed
|
|
729
|
+
}),
|
|
730
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
731
|
+
icon: "corners-out",
|
|
732
|
+
label: tr("重設視角"),
|
|
733
|
+
tooltip: false,
|
|
734
|
+
onClick: () => goTo(base, true),
|
|
735
|
+
disabled: !zoomed
|
|
736
|
+
})
|
|
737
|
+
]
|
|
738
|
+
})
|
|
739
|
+
]
|
|
740
|
+
}),
|
|
741
|
+
legend ? /* @__PURE__ */ jsx(Legend, {
|
|
742
|
+
min,
|
|
743
|
+
max,
|
|
744
|
+
unit,
|
|
745
|
+
warn: p.warn,
|
|
746
|
+
limit: p.limit,
|
|
747
|
+
decimals: zones.find((z) => z.decimals != null)?.decimals ?? 1,
|
|
748
|
+
muted: hasMuted
|
|
749
|
+
}) : null
|
|
750
|
+
]
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
/** The tooltip beside the point, kept inside the drawing. */
|
|
754
|
+
function tipStyle(x, y, W, H) {
|
|
755
|
+
const right = x > W - 240;
|
|
756
|
+
const below = y < 90;
|
|
757
|
+
return {
|
|
758
|
+
left: right ? void 0 : Math.max(4, x + 14),
|
|
759
|
+
right: right ? Math.max(4, W - x + 14) : void 0,
|
|
760
|
+
top: below ? Math.min(H - 4, y + 18) : void 0,
|
|
761
|
+
bottom: below ? void 0 : Math.max(4, H - y + 10)
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function Legend({ min, max, unit, warn, limit, decimals, muted }) {
|
|
765
|
+
const pct = (v) => `${Math.min(100, Math.max(0, (v - min) / (max - min) * 100))}%`;
|
|
766
|
+
const num = (v) => format.number(v, decimals) + (unit ? " " + unit : "");
|
|
767
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
768
|
+
className: "ui-fp-legend",
|
|
769
|
+
children: [
|
|
770
|
+
/* @__PURE__ */ jsxs("span", {
|
|
771
|
+
className: "ui-fp-scale",
|
|
772
|
+
children: [
|
|
773
|
+
/* @__PURE__ */ jsx("span", {
|
|
774
|
+
className: "ui-fp-num",
|
|
775
|
+
children: format.number(min, decimals)
|
|
776
|
+
}),
|
|
777
|
+
/* @__PURE__ */ jsxs("span", {
|
|
778
|
+
className: "ui-fp-bar",
|
|
779
|
+
children: [
|
|
780
|
+
[
|
|
781
|
+
1,
|
|
782
|
+
2,
|
|
783
|
+
3,
|
|
784
|
+
4,
|
|
785
|
+
5,
|
|
786
|
+
6,
|
|
787
|
+
7
|
|
788
|
+
].map((n) => /* @__PURE__ */ jsx("span", { style: { background: `var(--heat-${n})` } }, n)),
|
|
789
|
+
warn != null ? /* @__PURE__ */ jsx("span", {
|
|
790
|
+
className: "ui-fp-tick is-warning",
|
|
791
|
+
style: { left: pct(warn) }
|
|
792
|
+
}) : null,
|
|
793
|
+
limit != null ? /* @__PURE__ */ jsx("span", {
|
|
794
|
+
className: "ui-fp-tick is-danger",
|
|
795
|
+
style: { left: pct(limit) }
|
|
796
|
+
}) : null
|
|
797
|
+
]
|
|
798
|
+
}),
|
|
799
|
+
/* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
|
|
800
|
+
className: "ui-fp-num",
|
|
801
|
+
children: format.number(max, decimals)
|
|
802
|
+
}), unit ? "\xA0" + unit : ""] })
|
|
803
|
+
]
|
|
804
|
+
}),
|
|
805
|
+
warn != null ? /* @__PURE__ */ jsx("span", {
|
|
806
|
+
className: "ui-fp-key is-warning",
|
|
807
|
+
children: tr("注意 {v}", { v: num(warn) })
|
|
808
|
+
}) : null,
|
|
809
|
+
limit != null ? /* @__PURE__ */ jsx("span", {
|
|
810
|
+
className: "ui-fp-key is-danger",
|
|
811
|
+
children: tr("上限 {v}", { v: num(limit) })
|
|
812
|
+
}) : null,
|
|
813
|
+
muted ? /* @__PURE__ */ jsx("span", {
|
|
814
|
+
className: "ui-fp-key is-muted",
|
|
815
|
+
children: tr("淡色=次要區域")
|
|
816
|
+
}) : null
|
|
817
|
+
]
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
export { FloorPlan, insidePolygon, placeLabels, planBox, polygonArea, polygonPath, ringPath, screenOf, textWidth, zoneOrder };
|
|
821
|
+
|
|
822
|
+
//# sourceMappingURL=FloorPlan.js.map
|