@graview/pages 0.1.73 → 0.2.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/README.md +14 -0
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +11 -1
- package/dist/context-menu.js.map +1 -1
- package/dist/device.d.ts +146 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/device.js +564 -0
- package/dist/device.js.map +1 -0
- package/dist/face-controls.d.ts.map +1 -1
- package/dist/face-controls.js +17 -2
- package/dist/face-controls.js.map +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +3 -0
- package/dist/form.js.map +1 -1
- package/dist/one-place-city.d.ts +9 -0
- package/dist/one-place-city.d.ts.map +1 -0
- package/dist/one-place-city.js +960 -0
- package/dist/one-place-city.js.map +1 -0
- package/dist/one-place-control.d.ts +28 -0
- package/dist/one-place-control.d.ts.map +1 -0
- package/dist/one-place-control.js +5 -0
- package/dist/one-place-control.js.map +1 -0
- package/dist/one-place-geometry.d.ts +226 -0
- package/dist/one-place-geometry.d.ts.map +1 -0
- package/dist/one-place-geometry.js +434 -0
- package/dist/one-place-geometry.js.map +1 -0
- package/dist/one-place.d.ts +79 -0
- package/dist/one-place.d.ts.map +1 -0
- package/dist/one-place.js +1115 -0
- package/dist/one-place.js.map +1 -0
- package/dist/page-context.d.ts +9 -0
- package/dist/page-context.d.ts.map +1 -1
- package/dist/page-context.js +3 -0
- package/dist/page-context.js.map +1 -1
- package/dist/page-home.d.ts.map +1 -1
- package/dist/page-home.js +2 -2
- package/dist/page-home.js.map +1 -1
- package/dist/page-search.d.ts.map +1 -1
- package/dist/page-search.js +32 -4
- package/dist/page-search.js.map +1 -1
- package/dist/page-shell.d.ts.map +1 -1
- package/dist/page-shell.js +55 -10
- package/dist/page-shell.js.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +17 -3
- package/dist/router.js.map +1 -1
- package/dist/static-read.d.ts +45 -0
- package/dist/static-read.d.ts.map +1 -0
- package/dist/static-read.js +100 -0
- package/dist/static-read.js.map +1 -0
- package/dist/static.d.ts.map +1 -1
- package/dist/static.js +5 -80
- package/dist/static.js.map +1 -1
- package/package.json +10 -6
|
@@ -0,0 +1,1115 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { OVERVIEW_PATH, ONE_FACE_LAYERS, hueFor, labelOf } from "@graview/core";
|
|
3
|
+
import { retryingImport } from "@graview/core/retry";
|
|
4
|
+
import { barPlaces, HOME_KEY, PastBar } from "@graview/primitives/pages";
|
|
5
|
+
import { lazyPart, useGraview, usePlayback } from "@graview/react/provider";
|
|
6
|
+
import { Suspense, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { useHref, useLocation, useNavigate } from "react-router";
|
|
8
|
+
import { recordFacts } from "./facts.js";
|
|
9
|
+
import { useStoreTick } from "./page-context.js";
|
|
10
|
+
import { pluralOf } from "./page-typography.js";
|
|
11
|
+
import { kindOfSlug, recordPath, pluralSlug } from "./registry.js";
|
|
12
|
+
import { OneFaceContext } from "./one-place-control.js";
|
|
13
|
+
import { boardCut, CITY, LEVEL_NAMES, nearestThatWay, PAGE, PANEL, panelBox, panelRange, PHONE } from "./one-place-geometry.js";
|
|
14
|
+
/**
|
|
15
|
+
* PAGES AND THE SCENE ARE ONE PLACE (Graview HQ feature:f-page-zooms-out-to-the-city).
|
|
16
|
+
*
|
|
17
|
+
* The routed page is read over the Scene's own city — the `Scene` of
|
|
18
|
+
* `@graview/react`, mounted underneath in the same provider the pages draw
|
|
19
|
+
* with — and altitude is the Scene's own camera. There is one face: no
|
|
20
|
+
* switch between a scene and the pages, and no record "drive-in" of the
|
|
21
|
+
* Scene's own. The page the person is reading is the one element that
|
|
22
|
+
* moves, continuously, every step drawn:
|
|
23
|
+
*
|
|
24
|
+
* - L0, THE PAGE: the routed page, the whole window; the city not seen.
|
|
25
|
+
* - L1, BESIDE THE CITY: the same page, its box narrowed to a column beside
|
|
26
|
+
* the city (a sheet from the foot on a phone), the camera pulled back to
|
|
27
|
+
* its place, and a Connected list grown into its foot — what the record
|
|
28
|
+
* is linked to, each row with a line to its building.
|
|
29
|
+
* - L2, THE CITY: every page and view of the app a board standing on its
|
|
30
|
+
* place — the home, each kind's list, each lens — and this page among
|
|
31
|
+
* them, shrunk into its own board. Choosing a board (a press, Enter, or
|
|
32
|
+
* the button that comes down) comes down to that page beside the city.
|
|
33
|
+
*
|
|
34
|
+
* One button at the window's bottom left rises and comes down a level and
|
|
35
|
+
* says which level this is; Alt and the arrows, and Escape for down, do the
|
|
36
|
+
* same from the keyboard; a pinch or ctrl and the wheel scrub the camera,
|
|
37
|
+
* and the page with it, as far as the hand goes, settling to the nearest
|
|
38
|
+
* level when let go. A drag pans the camera. The address is the page's
|
|
39
|
+
* route at every level, so Back and Forward work.
|
|
40
|
+
*
|
|
41
|
+
* The city's part (`one-place-city.tsx`) — the Scene, the camera, the
|
|
42
|
+
* lines, the boards' places — is fetched as the page first draws.
|
|
43
|
+
*/
|
|
44
|
+
const OnePlaceCity = lazyPart(retryingImport(() => import("./one-place-city.js").then((module) => ({ default: module.OnePlaceCity }))));
|
|
45
|
+
const lessMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
46
|
+
const windowSize = () => ({ width: document.documentElement.clientWidth || window.innerWidth, height: window.innerHeight });
|
|
47
|
+
/** What the page's address is in the city. */
|
|
48
|
+
function whereOf(schema, has, pathname, placeKinds) {
|
|
49
|
+
if (pathname === OVERVIEW_PATH)
|
|
50
|
+
return { type: "overview" };
|
|
51
|
+
const segments = pathname.split("/").filter(Boolean).map((one) => {
|
|
52
|
+
try {
|
|
53
|
+
return decodeURIComponent(one);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return one;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (segments.length === 0)
|
|
60
|
+
return { type: "home" };
|
|
61
|
+
if (segments[0] === "places" && segments.length === 2) {
|
|
62
|
+
const kinds = placeKinds(segments[1]);
|
|
63
|
+
return kinds.length > 0 ? { type: "place", as: segments[1], kinds } : { type: "home" };
|
|
64
|
+
}
|
|
65
|
+
const kind = kindOfSlug(schema, segments[0]);
|
|
66
|
+
if (kind && segments.length === 1)
|
|
67
|
+
return { type: "list", kind };
|
|
68
|
+
if (kind && segments.length === 2 && has(segments[1]) === kind)
|
|
69
|
+
return { type: "record", id: segments[1], kind };
|
|
70
|
+
return { type: "home" };
|
|
71
|
+
}
|
|
72
|
+
/** The first few names a view of these kinds lists, for its sign. */
|
|
73
|
+
function firstOf(store, kinds) {
|
|
74
|
+
const names = [];
|
|
75
|
+
for (const kind of kinds) {
|
|
76
|
+
for (const node of store.graph.nodesOfKind(kind)) {
|
|
77
|
+
if (names.length >= 3)
|
|
78
|
+
return names;
|
|
79
|
+
names.push(labelOf(store.schema.tryDefinition(kind), node));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return names;
|
|
83
|
+
}
|
|
84
|
+
/** Which board a place is. */
|
|
85
|
+
const boardKeyOf = (where, boards) => {
|
|
86
|
+
if (where.type === "record")
|
|
87
|
+
return `record:${where.id}`;
|
|
88
|
+
const found = boards.find((board) => where.type === "home" || where.type === "overview"
|
|
89
|
+
? board.where.type === "home"
|
|
90
|
+
: where.type === "list"
|
|
91
|
+
? board.where.type === "list" && board.where.kind === where.kind
|
|
92
|
+
: board.where.type === "place" && board.where.as === where.as);
|
|
93
|
+
return found?.key ?? HOME_KEY;
|
|
94
|
+
};
|
|
95
|
+
/*
|
|
96
|
+
* THE CONTROL'S TOOLTIPS, ON INTENT. A pointer passing over shows nothing:
|
|
97
|
+
* a tooltip comes after the pointer has rested on a part for TIP_DELAY_MS,
|
|
98
|
+
* and goes TIP_HIDE_MS after it leaves. Once one has shown, the next part
|
|
99
|
+
* the pointer rests on shows its own at once, for TIP_WARM_MS after the last
|
|
100
|
+
* went (the way along the stops). The keyboard's focus shows it at once; a
|
|
101
|
+
* finger, only a long press.
|
|
102
|
+
*/
|
|
103
|
+
const TIP_DELAY_MS = 600;
|
|
104
|
+
const TIP_HIDE_MS = 100;
|
|
105
|
+
const TIP_WARM_MS = 300;
|
|
106
|
+
const TIP_PRESS_MS = 500;
|
|
107
|
+
/** When a tooltip of the control was last put away, for the warm window. */
|
|
108
|
+
let tipHiddenAt = -Infinity;
|
|
109
|
+
/** When a pointer last went down: a focus that follows a press is the pointer's, and shows no tooltip. */
|
|
110
|
+
let pressedAt = -Infinity;
|
|
111
|
+
if (typeof document !== "undefined")
|
|
112
|
+
document.addEventListener("pointerdown", () => (pressedAt = performance.now()), { capture: true, passive: true });
|
|
113
|
+
function useIntentTip() {
|
|
114
|
+
const [shown, setShown] = useState(null);
|
|
115
|
+
const showing = useRef(false);
|
|
116
|
+
const timer = useRef(undefined);
|
|
117
|
+
const clear = () => window.clearTimeout(timer.current);
|
|
118
|
+
useEffect(() => clear, []);
|
|
119
|
+
const show = (el, text) => {
|
|
120
|
+
clear();
|
|
121
|
+
const host = el.closest("[data-graview-tip-host]");
|
|
122
|
+
const left = host ? Math.max(0, el.getBoundingClientRect().left - host.getBoundingClientRect().left) : 0;
|
|
123
|
+
showing.current = true;
|
|
124
|
+
setShown({ text, left });
|
|
125
|
+
};
|
|
126
|
+
const hide = (after) => {
|
|
127
|
+
clear();
|
|
128
|
+
const go = () => {
|
|
129
|
+
if (showing.current)
|
|
130
|
+
tipHiddenAt = performance.now();
|
|
131
|
+
showing.current = false;
|
|
132
|
+
setShown(null);
|
|
133
|
+
};
|
|
134
|
+
if (after > 0)
|
|
135
|
+
timer.current = window.setTimeout(go, after);
|
|
136
|
+
else
|
|
137
|
+
go();
|
|
138
|
+
};
|
|
139
|
+
const on = (text) => ({
|
|
140
|
+
onPointerEnter: (event) => {
|
|
141
|
+
if (event.pointerType === "touch")
|
|
142
|
+
return;
|
|
143
|
+
const el = event.currentTarget;
|
|
144
|
+
clear();
|
|
145
|
+
if (showing.current || performance.now() - tipHiddenAt < TIP_WARM_MS)
|
|
146
|
+
show(el, text);
|
|
147
|
+
else
|
|
148
|
+
timer.current = window.setTimeout(() => show(el, text), TIP_DELAY_MS);
|
|
149
|
+
},
|
|
150
|
+
onPointerLeave: (event) => {
|
|
151
|
+
if (event.pointerType !== "touch")
|
|
152
|
+
hide(TIP_HIDE_MS);
|
|
153
|
+
},
|
|
154
|
+
onPointerDown: (event) => {
|
|
155
|
+
if (event.pointerType !== "touch")
|
|
156
|
+
return;
|
|
157
|
+
const el = event.currentTarget;
|
|
158
|
+
clear();
|
|
159
|
+
timer.current = window.setTimeout(() => show(el, text), TIP_PRESS_MS);
|
|
160
|
+
},
|
|
161
|
+
onPointerUp: (event) => {
|
|
162
|
+
// A finger lifted: what a long press showed stays a moment to be read; a tap showed nothing.
|
|
163
|
+
if (event.pointerType === "touch")
|
|
164
|
+
hide(showing.current ? 1500 : 0);
|
|
165
|
+
},
|
|
166
|
+
onPointerCancel: () => hide(0),
|
|
167
|
+
onFocus: (event) => {
|
|
168
|
+
// The keyboard's focus (or one moved there for it), not a press's.
|
|
169
|
+
if (event.currentTarget.matches(":focus-visible") || performance.now() - pressedAt > 400)
|
|
170
|
+
show(event.currentTarget, text);
|
|
171
|
+
},
|
|
172
|
+
onBlur: () => hide(0),
|
|
173
|
+
});
|
|
174
|
+
return { shown, on };
|
|
175
|
+
}
|
|
176
|
+
/** The tooltip itself: one for the control, over the part it is about. */
|
|
177
|
+
function Tip({ id, tip, said }) {
|
|
178
|
+
// The level's own tooltip is the description the stop and the slider are given, and says only that; another part's words are shown in one of their own.
|
|
179
|
+
const own = !tip.shown || tip.shown.text === said;
|
|
180
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { id: id, role: "tooltip", "data-graview-one-face-tip": "", "data-graview-shown": tip.shown && own ? "" : undefined, style: { left: tip.shown?.left ?? 0 }, children: said }), _jsx("span", { "aria-hidden": "true", "data-graview-one-face-tip": "", "data-graview-shown": tip.shown && !own ? "" : undefined, style: { left: tip.shown?.left ?? 0 }, children: own ? "" : tip.shown.text })] }));
|
|
181
|
+
}
|
|
182
|
+
/** Where this browser keeps whether the legend is shown beside the city. */
|
|
183
|
+
const LEGEND_KEY = "graview.one-face.legend";
|
|
184
|
+
/** Where this browser keeps whether the control is the three levels or a slider. */
|
|
185
|
+
const CONTROL_KEY = "graview.one-face.control";
|
|
186
|
+
/** The keys that go straight to each level, Page, Nearby and City. */
|
|
187
|
+
const LEVEL_KEYS = ["1", "2", "3"];
|
|
188
|
+
/** Where this browser keeps whether the level's single keys are on (WCAG 2.1.4: they can be turned off). */
|
|
189
|
+
const KEYS_KEY = "graview.one-face.keys";
|
|
190
|
+
const keysOn = () => {
|
|
191
|
+
try {
|
|
192
|
+
return window.localStorage.getItem(KEYS_KEY) !== "off";
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
/** Typing somewhere: the keys are the field's, not the altitude's. */
|
|
199
|
+
const typingIn = (target) => target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || (target instanceof HTMLElement && target.isContentEditable);
|
|
200
|
+
export function OnePlace({ context, children }) {
|
|
201
|
+
const { views } = useGraview();
|
|
202
|
+
const store = context.store;
|
|
203
|
+
const schema = store.schema;
|
|
204
|
+
// The views' signs say what their records are now: drawn again as the store changes.
|
|
205
|
+
const tick = useStoreTick(store);
|
|
206
|
+
const location = useLocation();
|
|
207
|
+
const navigate = useNavigate();
|
|
208
|
+
const base = useHref("/").replace(/\/$/, "");
|
|
209
|
+
const address = `${location.pathname}${location.search}`;
|
|
210
|
+
const has = useCallback((id) => store.graph.getNode(id)?.kind, [store]);
|
|
211
|
+
const placeKinds = useCallback((as) => [...new Set(views.places().filter((place) => place.as === as).flatMap((place) => (place.kind ? [place.kind] : [])))], [views]);
|
|
212
|
+
const where = useMemo(() => whereOf(schema, has, location.pathname, placeKinds), [schema, has, location.pathname, placeKinds]);
|
|
213
|
+
const [size, setView] = useState(() => (typeof window === "undefined" ? { width: 1280, height: 800 } : windowSize()));
|
|
214
|
+
/* The app's bar, fixed at the window's top at every level: its slot, and how tall it stands. */
|
|
215
|
+
const [bar, setBar] = useState(null);
|
|
216
|
+
const [barHeight, setBarHeight] = useState(0);
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
if (!bar || typeof ResizeObserver === "undefined")
|
|
219
|
+
return;
|
|
220
|
+
const measure = () => setBarHeight(Math.ceil(bar.getBoundingClientRect().height));
|
|
221
|
+
measure();
|
|
222
|
+
const watch = new ResizeObserver(measure);
|
|
223
|
+
watch.observe(bar);
|
|
224
|
+
return () => watch.disconnect();
|
|
225
|
+
}, [bar]);
|
|
226
|
+
/*
|
|
227
|
+
* THE PANEL AS THE PERSON SIZED IT: dragged by its inner edge, or stepped
|
|
228
|
+
* by the arrow keys there — a desk's panel's width, a phone's sheet's
|
|
229
|
+
* height (the share of the window above it). Kept in this browser, for
|
|
230
|
+
* the moves between levels to start and end from.
|
|
231
|
+
*/
|
|
232
|
+
const phoneNow = size.width <= PHONE;
|
|
233
|
+
const panelKey = `graview.one-face.panel.${phoneNow ? "phone" : "desk"}`;
|
|
234
|
+
const [panelSize, setPanelSize] = useState(() => {
|
|
235
|
+
try {
|
|
236
|
+
const kept = typeof window === "undefined" ? null : window.localStorage.getItem(`graview.one-face.panel.${windowSize().width <= PHONE ? "phone" : "desk"}`);
|
|
237
|
+
return kept === null ? undefined : Number(kept) || undefined;
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
// Across the phone's width the size is the other device's: read again for it.
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
try {
|
|
246
|
+
const kept = window.localStorage.getItem(panelKey);
|
|
247
|
+
setPanelSize(kept === null ? undefined : Number(kept) || undefined);
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
setPanelSize(undefined);
|
|
251
|
+
}
|
|
252
|
+
}, [panelKey]);
|
|
253
|
+
/** The size, now; kept in this browser once the hand lets go (`keepPanel`), not on every move. */
|
|
254
|
+
const sizePanel = useCallback((to) => setPanelSize(to), []);
|
|
255
|
+
const panelHeld = useRef(panelSize);
|
|
256
|
+
panelHeld.current = panelSize;
|
|
257
|
+
const keepPanel = useCallback(() => {
|
|
258
|
+
try {
|
|
259
|
+
const to = panelHeld.current;
|
|
260
|
+
if (to === undefined)
|
|
261
|
+
window.localStorage.removeItem(panelKey);
|
|
262
|
+
else
|
|
263
|
+
window.localStorage.setItem(panelKey, String(Math.round(to * 1000) / 1000));
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// A browser that keeps nothing keeps the size for this visit.
|
|
267
|
+
}
|
|
268
|
+
}, [panelKey]);
|
|
269
|
+
const view = useMemo(() => ({ ...size, top: barHeight, ...(panelSize !== undefined ? { panel: panelSize } : {}) }), [size, barHeight, panelSize]);
|
|
270
|
+
const motion = useRef({ level: where.type === "overview" ? CITY : null, scrub: 0, scrubbing: false, held: false, resizing: false });
|
|
271
|
+
// What the camera says: the level rested at or headed for, and whether the page is out of the window.
|
|
272
|
+
const [now, setNow] = useState({ level: PAGE, away: where.type === "overview", moving: false });
|
|
273
|
+
const sheet = useRef(null);
|
|
274
|
+
const connected = useRef(null);
|
|
275
|
+
const fab = useRef(null);
|
|
276
|
+
const boardLayer = useRef(null);
|
|
277
|
+
const boardEls = useRef(new Map());
|
|
278
|
+
/** The board last given the keyboard at the city: the button that comes down goes into it. */
|
|
279
|
+
const chosen = useRef(null);
|
|
280
|
+
/** Put down at the city by a press on the ground or Escape: the keyboard is not put back on a view until a level is moved. */
|
|
281
|
+
const deselected = useRef(false);
|
|
282
|
+
const kept = useRef(null);
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
const resized = () => setView(windowSize());
|
|
285
|
+
window.addEventListener("resize", resized);
|
|
286
|
+
return () => window.removeEventListener("resize", resized);
|
|
287
|
+
}, []);
|
|
288
|
+
/*
|
|
289
|
+
* THE BOARDS: every page and view the app offers — its home, each kind's
|
|
290
|
+
* list, each lens, as the bar's places list them, lists and lenses alike
|
|
291
|
+
* — and, on a record's page, that record's own.
|
|
292
|
+
*/
|
|
293
|
+
const boards = useMemo(() => {
|
|
294
|
+
const places = barPlaces({ store: store, principal: context.principal, views: context.views }).filter((place) => !place.hidden);
|
|
295
|
+
const out = places.map((place) => ({
|
|
296
|
+
key: place.key,
|
|
297
|
+
label: place.label,
|
|
298
|
+
path: place.path,
|
|
299
|
+
eyebrow: place.group === "home" ? "home" : place.group === "lists" ? "list" : "view",
|
|
300
|
+
lines: firstOf(store, place.kind ? [place.kind] : store.schema.kinds.slice(0, 1)),
|
|
301
|
+
kind: place.kind,
|
|
302
|
+
where: whereOf(schema, has, place.path.split("?")[0], placeKinds),
|
|
303
|
+
}));
|
|
304
|
+
if (where.type === "record") {
|
|
305
|
+
const node = store.graph.getNode(where.id);
|
|
306
|
+
out.push({ key: `record:${where.id}`, label: node ? labelOf(store.schema.tryDefinition(node.kind), node) : where.id, path: recordPath(schema, where.kind, where.id), eyebrow: "page", lines: [], kind: where.kind, where });
|
|
307
|
+
}
|
|
308
|
+
return out;
|
|
309
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
310
|
+
}, [store, context.principal, context.views, schema, has, placeKinds, where, tick]);
|
|
311
|
+
const current = boardKeyOf(where, boards);
|
|
312
|
+
/* While the history is played, a view that comes into being rises out of the city, and one that goes sinks back into it. */
|
|
313
|
+
const rising = Boolean(usePlayback()?.open) && !lessMotion();
|
|
314
|
+
const leaving = useLeavingBoards(boards, rising);
|
|
315
|
+
const standing = useMemo(() => (leaving.length > 0 ? [...boards, ...leaving] : boards), [boards, leaving]);
|
|
316
|
+
/** Out of the window: where the page was scrolled, for the page as it moves and for the way back in. */
|
|
317
|
+
const keep = () => {
|
|
318
|
+
if (!now.away && !kept.current)
|
|
319
|
+
kept.current = { scrollY: window.scrollY, address };
|
|
320
|
+
};
|
|
321
|
+
const goLevel = useCallback((level) => {
|
|
322
|
+
const to = Math.max(PAGE, Math.min(CITY, level));
|
|
323
|
+
if (to > PAGE)
|
|
324
|
+
keep();
|
|
325
|
+
motion.current.level = to;
|
|
326
|
+
// The page leaves the window in this commit, so the first frame of the move draws it where it was.
|
|
327
|
+
if (to > PAGE)
|
|
328
|
+
setNow((was) => (was.away ? was : { ...was, away: true }));
|
|
329
|
+
},
|
|
330
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
331
|
+
[now.away, address]);
|
|
332
|
+
/* Out of the window, the page keeps its own scroll; in again, the window takes it back. */
|
|
333
|
+
useLayoutEffect(() => {
|
|
334
|
+
const plane = sheet.current;
|
|
335
|
+
if (!plane)
|
|
336
|
+
return;
|
|
337
|
+
if (now.away) {
|
|
338
|
+
if (kept.current)
|
|
339
|
+
plane.scrollTop = kept.current.address === address ? kept.current.scrollY : 0;
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const was = kept.current;
|
|
343
|
+
kept.current = null;
|
|
344
|
+
if (was)
|
|
345
|
+
window.scrollTo({ left: 0, top: was.address === address ? was.scrollY : 0, behavior: "instant" });
|
|
346
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
347
|
+
}, [now.away]);
|
|
348
|
+
/* The overview's own address is the city, standing over the home: the address the home's. */
|
|
349
|
+
useEffect(() => {
|
|
350
|
+
if (where.type !== "overview")
|
|
351
|
+
return;
|
|
352
|
+
motion.current.level = CITY;
|
|
353
|
+
setNow((was) => ({ ...was, away: true }));
|
|
354
|
+
navigate(`/${location.search}`, { replace: true });
|
|
355
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
356
|
+
}, [where.type]);
|
|
357
|
+
/** Another place, at a level: its address, and the camera asked to that level there. */
|
|
358
|
+
const openAt = useCallback((path, level) => {
|
|
359
|
+
if (path.split("?")[0] === location.pathname)
|
|
360
|
+
return goLevel(level);
|
|
361
|
+
if (level > PAGE)
|
|
362
|
+
keep();
|
|
363
|
+
kept.current = level > PAGE ? { scrollY: 0, address: path } : null;
|
|
364
|
+
motion.current.level = level;
|
|
365
|
+
if (level > PAGE)
|
|
366
|
+
setNow((was) => (was.away ? was : { ...was, away: true }));
|
|
367
|
+
navigate(path);
|
|
368
|
+
},
|
|
369
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
370
|
+
[location.pathname, goLevel, navigate]);
|
|
371
|
+
const openRecord = useCallback((id, level) => {
|
|
372
|
+
const kind = has(id);
|
|
373
|
+
if (kind)
|
|
374
|
+
openAt(recordPath(schema, kind, id), level);
|
|
375
|
+
}, [has, schema, openAt]);
|
|
376
|
+
const openKind = useCallback((kind, level) => {
|
|
377
|
+
// A place that shows this kind is already its page.
|
|
378
|
+
if (where.type === "place" && where.kinds.includes(kind))
|
|
379
|
+
return goLevel(level);
|
|
380
|
+
openAt(`/${pluralSlug(schema, kind)}`, level);
|
|
381
|
+
}, [schema, where, goLevel, openAt]);
|
|
382
|
+
const resolve = useCallback((pathname) => {
|
|
383
|
+
const path = base && pathname.startsWith(base) ? pathname.slice(base.length) || "/" : pathname;
|
|
384
|
+
const found = whereOf(schema, has, path, placeKinds);
|
|
385
|
+
return found.type === "record" || found.type === "list" ? found : null;
|
|
386
|
+
}, [base, schema, has, placeKinds]);
|
|
387
|
+
/** Into a board, beside the city: this page's own, or another's. */
|
|
388
|
+
const intoBoard = useCallback((key) => {
|
|
389
|
+
const board = boards.find((one) => one.key === key);
|
|
390
|
+
if (!board || key === current)
|
|
391
|
+
return goLevel(PANEL);
|
|
392
|
+
openAt(board.path, PANEL);
|
|
393
|
+
}, [boards, current, goLevel, openAt]);
|
|
394
|
+
/** To a level from here: from the city down, into the board the keyboard chose, if it chose another. */
|
|
395
|
+
const goTo = useCallback((level) => {
|
|
396
|
+
const to = Math.max(PAGE, Math.min(CITY, level));
|
|
397
|
+
if (now.level === CITY && to < CITY && chosen.current && chosen.current !== current) {
|
|
398
|
+
const board = boards.find((one) => one.key === chosen.current);
|
|
399
|
+
if (board)
|
|
400
|
+
return openAt(board.path, to);
|
|
401
|
+
}
|
|
402
|
+
goLevel(to);
|
|
403
|
+
}, [now.level, current, boards, goLevel, openAt]);
|
|
404
|
+
const rise = useCallback(() => goTo(now.level + 1), [goTo, now.level]);
|
|
405
|
+
const descend = useCallback(() => goTo(now.level - 1), [goTo, now.level]);
|
|
406
|
+
/*
|
|
407
|
+
* A PINCH, OR CTRL AND THE WHEEL, SCRUBS THE ALTITUDE: on the page and on
|
|
408
|
+
* the panel this face moves the camera itself, as far as the hand goes;
|
|
409
|
+
* over the city the Scene's own hand zooms it, and the altitude is read
|
|
410
|
+
* off its zoom. Nothing snaps: let go, it settles to the nearest level.
|
|
411
|
+
* Alt and the up arrow rise a level, Alt and the down arrow (or Escape)
|
|
412
|
+
* come down one — never while the keys are writing in a field.
|
|
413
|
+
*/
|
|
414
|
+
/**
|
|
415
|
+
* NO VIEW CHOSEN: the keyboard off every view, onto the views' own group,
|
|
416
|
+
* and the city as it is. A press on bare ground at the city does it, and
|
|
417
|
+
* Escape there.
|
|
418
|
+
*/
|
|
419
|
+
const deselect = useCallback(() => {
|
|
420
|
+
chosen.current = null;
|
|
421
|
+
deselected.current = true;
|
|
422
|
+
boardLayer.current?.focus({ preventScroll: true });
|
|
423
|
+
}, []);
|
|
424
|
+
/** Out of the window's flow, ready for a hand to move the camera. */
|
|
425
|
+
const beginAway = useCallback(() => {
|
|
426
|
+
if (latest.current.now.away)
|
|
427
|
+
return;
|
|
428
|
+
latest.current.keep();
|
|
429
|
+
setNow((was) => (was.away ? was : { ...was, away: true }));
|
|
430
|
+
}, []);
|
|
431
|
+
const onGround = useCallback(() => {
|
|
432
|
+
if (latest.current.now.level === CITY && !latest.current.now.moving)
|
|
433
|
+
latest.current.deselect();
|
|
434
|
+
}, []);
|
|
435
|
+
const latest = useRef({ now, rise, descend, deselect, keep, goTo });
|
|
436
|
+
latest.current = { now, rise, descend, deselect, keep, goTo };
|
|
437
|
+
useEffect(() => {
|
|
438
|
+
const onPage = (target) => target instanceof Node && sheet.current?.contains(target) === true;
|
|
439
|
+
const begin = () => {
|
|
440
|
+
if (!latest.current.now.away) {
|
|
441
|
+
latest.current.keep();
|
|
442
|
+
setNow((was) => (was.away ? was : { ...was, away: true }));
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
let pinch = null;
|
|
446
|
+
const apart = (touches) => Math.hypot(touches[0].clientX - touches[1].clientX, touches[0].clientY - touches[1].clientY);
|
|
447
|
+
const touchStart = (event) => {
|
|
448
|
+
motion.current.held = event.touches.length > 0;
|
|
449
|
+
/*
|
|
450
|
+
* A PINCH IS THE BROWSER'S OWN ON THE PAGE: there it zooms the page's
|
|
451
|
+
* words for whoever needs them larger, and a level is moved by the
|
|
452
|
+
* control, its keys, or Alt and the arrows. Ctrl and the wheel, a
|
|
453
|
+
* trackpad's pinch, are the browser's own over the page too. Beside the
|
|
454
|
+
* city two fingers on the page scrub the altitude; over the city, and
|
|
455
|
+
* at the City, the Scene's own hand zooms the camera.
|
|
456
|
+
*/
|
|
457
|
+
const nearby = latest.current.now.level === PANEL && latest.current.now.away && !latest.current.now.moving;
|
|
458
|
+
const mine = nearby && onPage(event.touches[0]?.target ?? null) && onPage(event.touches[1]?.target ?? null);
|
|
459
|
+
pinch = event.touches.length === 2 && mine ? apart(event.touches) : null;
|
|
460
|
+
};
|
|
461
|
+
const touchMove = (event) => {
|
|
462
|
+
if (pinch === null || event.touches.length !== 2)
|
|
463
|
+
return;
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
begin();
|
|
466
|
+
const distance = apart(event.touches);
|
|
467
|
+
// Fingers together is out: the altitude rises as far as they have closed.
|
|
468
|
+
motion.current.scrub += Math.log(pinch / distance) * 1.6;
|
|
469
|
+
pinch = distance;
|
|
470
|
+
};
|
|
471
|
+
const touchEnd = (event) => {
|
|
472
|
+
motion.current.held = event.touches.length > 0;
|
|
473
|
+
if (event.touches.length < 2)
|
|
474
|
+
pinch = null;
|
|
475
|
+
};
|
|
476
|
+
const key = (event) => {
|
|
477
|
+
// Never with the browser's own chords (its zoom is Cmd or Ctrl and plus, minus, 0), never while the keys are writing, never into a view's frame.
|
|
478
|
+
const target = (event.composedPath()[0] ?? event.target);
|
|
479
|
+
if (event.defaultPrevented || event.repeat || event.isComposing || event.metaKey || event.ctrlKey || event.shiftKey || typingIn(target))
|
|
480
|
+
return;
|
|
481
|
+
// Where the keys mean something of their own — a menu, a list to type into, a grid — they are theirs.
|
|
482
|
+
if (target instanceof Element && target.closest('[role="menu"], [role="listbox"], [role="combobox"], [role="grid"], [role="textbox"], [role="spinbutton"], [role="tree"]'))
|
|
483
|
+
return;
|
|
484
|
+
if (document.querySelector("[data-graview-overlay]:not([hidden])"))
|
|
485
|
+
return;
|
|
486
|
+
const level = latest.current.now.level;
|
|
487
|
+
// 1, 2 and 3: Page, Nearby and City. [ and ]: down and up a level — unless the keys were turned off in the legend.
|
|
488
|
+
if (!event.altKey && !keysOn()) {
|
|
489
|
+
if (LEVEL_KEYS.includes(event.key) || event.key === "[" || event.key === "]")
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const stop = !event.altKey ? LEVEL_KEYS.indexOf(event.key) : -1;
|
|
493
|
+
if (stop >= 0) {
|
|
494
|
+
event.preventDefault();
|
|
495
|
+
if (stop !== level)
|
|
496
|
+
latest.current.goTo(stop);
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const up = (event.altKey && event.key === "ArrowUp") || (!event.altKey && event.key === "]");
|
|
500
|
+
// Escape at the city puts down the view the keyboard chose, and stays at the city; below it, it comes down a level.
|
|
501
|
+
if (!event.altKey && event.key === "Escape" && level === CITY) {
|
|
502
|
+
if (boardLayer.current?.contains(document.activeElement)) {
|
|
503
|
+
event.preventDefault();
|
|
504
|
+
latest.current.deselect();
|
|
505
|
+
}
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const down = (event.altKey && event.key === "ArrowDown") || (!event.altKey && (event.key === "Escape" || event.key === "["));
|
|
509
|
+
if (up && level < CITY) {
|
|
510
|
+
event.preventDefault();
|
|
511
|
+
latest.current.rise();
|
|
512
|
+
}
|
|
513
|
+
else if (down && level > PAGE) {
|
|
514
|
+
event.preventDefault();
|
|
515
|
+
latest.current.descend();
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
window.addEventListener("touchstart", touchStart, { passive: true, capture: true });
|
|
519
|
+
window.addEventListener("touchmove", touchMove, { passive: false, capture: true });
|
|
520
|
+
window.addEventListener("touchend", touchEnd, { capture: true });
|
|
521
|
+
window.addEventListener("touchcancel", touchEnd, { capture: true });
|
|
522
|
+
document.addEventListener("keydown", key);
|
|
523
|
+
return () => {
|
|
524
|
+
window.removeEventListener("touchstart", touchStart, { capture: true });
|
|
525
|
+
window.removeEventListener("touchmove", touchMove, { capture: true });
|
|
526
|
+
window.removeEventListener("touchend", touchEnd, { capture: true });
|
|
527
|
+
window.removeEventListener("touchcancel", touchEnd, { capture: true });
|
|
528
|
+
document.removeEventListener("keydown", key);
|
|
529
|
+
};
|
|
530
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
531
|
+
}, []);
|
|
532
|
+
const onAltitude = useCallback((told) => {
|
|
533
|
+
setNow((was) => (was.level === told.level && was.away === told.away && was.moving === told.moving ? was : told));
|
|
534
|
+
}, []);
|
|
535
|
+
/*
|
|
536
|
+
* WHERE THE KEYBOARD WAITS. At the city the page takes none: it waits on
|
|
537
|
+
* this page's own board, laid over it, unless it is already on a board or
|
|
538
|
+
* the button. Headed back down, a keyboard left on a board (going out of
|
|
539
|
+
* reach) goes to the page's title.
|
|
540
|
+
*/
|
|
541
|
+
const cameFrom = useRef(now.level);
|
|
542
|
+
useLayoutEffect(() => {
|
|
543
|
+
const active = document.activeElement;
|
|
544
|
+
const onBoards = boardLayer.current?.contains(active) === true;
|
|
545
|
+
// Only a move between levels places the keyboard: a page that opens at Page leaves it where the routed face puts it, as the derived pages do.
|
|
546
|
+
const moved = cameFrom.current !== now.level;
|
|
547
|
+
cameFrom.current = now.level;
|
|
548
|
+
if (now.level === CITY) {
|
|
549
|
+
if (now.moving || onBoards || fab.current?.contains(active) || deselected.current || bar?.contains(active))
|
|
550
|
+
return;
|
|
551
|
+
boardEls.current.get(current)?.focus({ preventScroll: true });
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
chosen.current = null;
|
|
555
|
+
deselected.current = false;
|
|
556
|
+
if (!onBoards && (active !== document.body || !moved))
|
|
557
|
+
return;
|
|
558
|
+
const title = sheet.current?.querySelector("main h1, h1:not([data-graview-app-bar] h1)");
|
|
559
|
+
if (title) {
|
|
560
|
+
if (!title.hasAttribute("tabindex"))
|
|
561
|
+
title.setAttribute("tabindex", "-1");
|
|
562
|
+
title.focus({ preventScroll: true });
|
|
563
|
+
}
|
|
564
|
+
else
|
|
565
|
+
fab.current?.querySelector("button")?.focus({ preventScroll: true });
|
|
566
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
567
|
+
}, [now.level, now.moving, current, bar]);
|
|
568
|
+
const face = useMemo(() => ({ level: now.level, goLevel, openRecord, openPath: openAt, bar }), [now.level, goLevel, openRecord, openAt, bar]);
|
|
569
|
+
const away = now.away;
|
|
570
|
+
// The page as one element: in the page's own flow while it is read, the window's box and then the panel's once it moves (`one-place-city.tsx` sets its box each frame).
|
|
571
|
+
const sheetStyle = away
|
|
572
|
+
? {
|
|
573
|
+
position: "fixed",
|
|
574
|
+
left: 0,
|
|
575
|
+
top: view.top,
|
|
576
|
+
width: view.width,
|
|
577
|
+
height: view.height - view.top,
|
|
578
|
+
overflowY: "auto",
|
|
579
|
+
overflowX: "hidden",
|
|
580
|
+
zIndex: ONE_FACE_LAYERS.page,
|
|
581
|
+
background: "var(--graview-ground, Canvas)",
|
|
582
|
+
boxShadow: "0 18px 50px rgba(0,0,0,0.20)",
|
|
583
|
+
outline: "1px solid var(--graview-edge)",
|
|
584
|
+
// At the city it takes no pointer: its board, laid over it, does.
|
|
585
|
+
pointerEvents: now.level >= CITY || now.moving ? "none" : "auto",
|
|
586
|
+
willChange: "transform, left, top, width, height",
|
|
587
|
+
// Its own sizes for its words: it is a narrower page as a panel.
|
|
588
|
+
containerType: "inline-size",
|
|
589
|
+
// Out of the window's flow the page is under the bar already: the room it kept for it is none.
|
|
590
|
+
["--graview-one-face-bar"]: "0px",
|
|
591
|
+
}
|
|
592
|
+
: { display: "contents", ["--graview-one-face-bar"]: `${barHeight}px` };
|
|
593
|
+
const subject = where.type === "record" ? where.id : null;
|
|
594
|
+
const panel = panelBox(view);
|
|
595
|
+
/* The arrow keys among the boards: the nearest that way. */
|
|
596
|
+
const boardKeys = (event) => {
|
|
597
|
+
const ways = { ArrowLeft: "left", ArrowRight: "right", ArrowUp: "up", ArrowDown: "down" };
|
|
598
|
+
const way = ways[event.key];
|
|
599
|
+
if (!way || event.altKey || event.metaKey || event.ctrlKey)
|
|
600
|
+
return;
|
|
601
|
+
const at = event.target.closest("[data-graview-board]");
|
|
602
|
+
if (!at)
|
|
603
|
+
return;
|
|
604
|
+
const boxOf = (el) => {
|
|
605
|
+
const r = el.getBoundingClientRect();
|
|
606
|
+
return { x: r.left, y: r.top, width: r.width, height: r.height };
|
|
607
|
+
};
|
|
608
|
+
const others = [...boardEls.current.entries()].filter(([, el]) => el !== at && Number(el.style.opacity || 0) > 0.5 && el.getBoundingClientRect().width > 0).map(([key, el]) => ({ key, box: boxOf(el) }));
|
|
609
|
+
const next = nearestThatWay(boxOf(at), others, way);
|
|
610
|
+
event.preventDefault();
|
|
611
|
+
if (next)
|
|
612
|
+
boardEls.current.get(next)?.focus({ preventScroll: true });
|
|
613
|
+
};
|
|
614
|
+
return (_jsxs(OneFaceContext.Provider, { value: face, children: [_jsx("div", { ref: setBar, "data-testid": "one-place-bar", style: { position: "fixed", left: 0, right: 0, top: 0, zIndex: ONE_FACE_LAYERS.bar, background: "var(--graview-ground, Canvas)" } }), _jsx(Suspense, { fallback: null, children: _jsx(OnePlaceCity, { where: where, out: now.away, sheet: sheet, connected: connected, boards: standing, current: current, boardEls: boardEls, boardLayer: boardLayer, fab: fab, view: view, lessMotion: lessMotion(), resolve: resolve, openRecord: openRecord, openKind: openKind, onGround: onGround, motion: motion, onAltitude: onAltitude }) }), _jsx("div", { ref: sheet, "data-graview-one-place": now.level, "data-graview-standing-on": where.type === "record" ? where.id : where.type === "list" ? `kind:${where.kind}` : where.type, style: sheetStyle, children: _jsxs("div", { ...(now.level >= CITY ? { inert: true } : {}), style: away ? { minHeight: "100%", display: "flex", flexDirection: "column" } : { display: "contents" }, children: [children, away && subject ? _jsx(Connected, { store: store, id: subject, box: connected, sheet: sheet, openRecord: openRecord }) : null, away ? null : _jsx(FootRoom, { fab: fab, sheet: sheet })] }) }), _jsx("div", { ref: boardLayer, role: "group", "aria-label": "The app's views", "data-testid": "one-place-boards", tabIndex: -1, onKeyDown: boardKeys, hidden: now.level < PANEL && !now.moving, style: { position: "fixed", left: 0, top: 0, width: 0, height: 0, zIndex: ONE_FACE_LAYERS.marks }, children: standing.map((board) => (_jsx("button", { ref: (el) => {
|
|
615
|
+
if (el)
|
|
616
|
+
boardEls.current.set(board.key, el);
|
|
617
|
+
else
|
|
618
|
+
boardEls.current.delete(board.key);
|
|
619
|
+
}, type: "button", "data-graview-board": board.key, ...(rising ? { "data-graview-rising": "" } : {}), ...(leaving.includes(board) ? { "data-graview-leaving": "", tabIndex: -1, "aria-hidden": true } : {}), "data-graview-board-path": board.path, ...(board.key === current ? { "aria-current": "page" } : {}), "aria-label": `${board.label}, ${board.eyebrow}${board.key === current ? ", the one you were on" : ""}`, title: board.label, onClick: () => intoBoard(board.key), onFocus: () => {
|
|
620
|
+
chosen.current = board.key;
|
|
621
|
+
}, className: "graview-one-place-board", style: { position: "fixed", left: 0, top: 0, width: 0, height: 0, padding: 0, margin: 0, border: "none", background: "none", cursor: "pointer", overflow: "visible", display: "block", opacity: 0, color: "inherit", font: "inherit", textAlign: "start" }, children: board.key === current ? null : _jsx(BoardFace, { board: board, width: panel.width, height: boardCut(panel) }) }, board.key))) }), now.level === PANEL && !now.moving ? _jsx(PanelEdge, { view: view, size: sizePanel, keep: keepPanel, motion: motion }) : null, _jsx(Altitude, { box: fab, level: now.level, moving: now.moving, goTo: goTo, where: where, chosen: chosen, boards: boards, current: current, store: store, motion: motion, begin: beginAway }), _jsx("style", { children: ONE_PLACE_CSS })] }));
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* A BOARD'S FACE: the top of its page as the page draws it — what it is,
|
|
625
|
+
* its title — at the page's own size, scaled by the city part
|
|
626
|
+
* with the camera, so a board and the page that becomes one read alike.
|
|
627
|
+
*/
|
|
628
|
+
function BoardFace({ board, width, height }) {
|
|
629
|
+
const hue = board.kind ? `hsl(${Math.round(hueFor(board.kind))} 55% 52%)` : "var(--graview-accent)";
|
|
630
|
+
return (_jsx("div", { "data-graview-board-face": "", "aria-hidden": "true", style: { position: "absolute", left: 0, top: 0, width, height, transformOrigin: "0 0", background: "var(--graview-ground, Canvas)", border: "3px solid var(--graview-edge)", borderTop: `10px solid ${hue}`, borderRadius: 18, overflow: "hidden", boxShadow: "0 18px 40px rgba(0,0,0,0.28)", pointerEvents: "none" }, children: _jsxs("div", { style: { padding: "26px 34px 0" }, children: [_jsx("div", { style: { fontSize: "4rem", lineHeight: 1.08, fontWeight: 650, color: "var(--graview-ink)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: board.label }), _jsx("div", { style: { marginTop: 18, display: "grid", gap: 12 }, children: board.lines.map((line, index) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 16, padding: "10px 16px", borderRadius: 12, border: "2px solid var(--graview-edge)", fontSize: "2.125rem", color: "var(--graview-ink-muted)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: [_jsx("span", { style: { flex: "0 0 auto", width: 18, height: 18, borderRadius: 9, border: `3px solid ${hue}` } }), line] }, index))) })] }) }));
|
|
631
|
+
}
|
|
632
|
+
/** How long a board takes to rise out of the city or sink into it, as a building does while the history plays. */
|
|
633
|
+
const RISE_MS = 420;
|
|
634
|
+
/**
|
|
635
|
+
* The views going while the history is played: kept as they were for as
|
|
636
|
+
* long as they take to sink, unless they come back first. Worked out as
|
|
637
|
+
* the list changes, in the render that changes it (state set from the
|
|
638
|
+
* last render's list, as React has it), so a view going keeps its element.
|
|
639
|
+
*/
|
|
640
|
+
function useLeavingBoards(boards, rising) {
|
|
641
|
+
const key = boards.map((board) => board.key).join("\n");
|
|
642
|
+
const [seen, setSeen] = useState({ key, boards });
|
|
643
|
+
const [gone, setGone] = useState(new Map());
|
|
644
|
+
if (seen.key !== key) {
|
|
645
|
+
setSeen({ key, boards });
|
|
646
|
+
const here = new Set(boards.map((board) => board.key));
|
|
647
|
+
const next = new Map([...gone].filter(([one]) => !here.has(one)));
|
|
648
|
+
if (rising)
|
|
649
|
+
for (const board of seen.boards)
|
|
650
|
+
if (!here.has(board.key) && board.where.type !== "record" && !next.has(board.key))
|
|
651
|
+
next.set(board.key, { board, until: performance.now() + RISE_MS });
|
|
652
|
+
setGone(next);
|
|
653
|
+
}
|
|
654
|
+
useEffect(() => {
|
|
655
|
+
if (!rising && gone.size > 0)
|
|
656
|
+
return setGone(new Map());
|
|
657
|
+
if (gone.size === 0)
|
|
658
|
+
return;
|
|
659
|
+
const next = Math.min(...[...gone.values()].map((one) => one.until));
|
|
660
|
+
const timer = window.setTimeout(() => setGone((was) => new Map([...was].filter(([, one]) => one.until > performance.now() + 4))), Math.max(0, next - performance.now()) + 8);
|
|
661
|
+
return () => window.clearTimeout(timer);
|
|
662
|
+
}, [gone, rising]);
|
|
663
|
+
const kept = useMemo(() => [...gone.values()].map((one) => one.board), [gone]);
|
|
664
|
+
return rising ? kept : [];
|
|
665
|
+
}
|
|
666
|
+
const ONE_PLACE_CSS = `
|
|
667
|
+
.graview-one-place-edge::after { content: ""; position: absolute; border-radius: 3px; background: color-mix(in srgb, var(--graview-ink) 28%, transparent); transition: background 120ms; }
|
|
668
|
+
.graview-one-place-edge[aria-orientation="vertical"]::after { left: 5px; top: 50%; width: 4px; height: 44px; margin-top: -22px; }
|
|
669
|
+
.graview-one-place-edge[aria-orientation="horizontal"]::after { top: 11px; left: 50%; height: 5px; width: 40px; margin-left: -20px; }
|
|
670
|
+
.graview-one-place-edge:hover::after, .graview-one-place-edge:focus-visible::after { background: var(--graview-accent); }
|
|
671
|
+
.graview-one-place-edge:focus-visible { outline: none; }
|
|
672
|
+
.graview-one-place-board::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: var(--graview-sign-post, 10px); margin-left: -1px; background: color-mix(in srgb, var(--graview-ink) 35%, transparent); }
|
|
673
|
+
.graview-one-place-board::before { content: ""; position: absolute; left: 50%; top: calc(100% + var(--graview-sign-post, 10px)); width: 18px; height: 6px; margin: -3px 0 0 -9px; border-radius: 50%; background: rgba(0,0,0,0.28); }
|
|
674
|
+
.graview-one-place-board[data-graview-rising] { transform-origin: 50% 100%; transform: scaleY(1); transition: transform ${RISE_MS}ms cubic-bezier(.33,0,.2,1); }
|
|
675
|
+
@starting-style { .graview-one-place-board[data-graview-rising] { transform: scaleY(0); } }
|
|
676
|
+
.graview-one-place-board[data-graview-rising][data-graview-leaving] { transform: scaleY(0); pointer-events: none; }
|
|
677
|
+
.graview-one-place-board[aria-current] { outline: 2px solid color-mix(in srgb, var(--graview-accent) 60%, transparent); outline-offset: 3px; border-radius: 4px; }
|
|
678
|
+
[data-graview-past-slot] > * { pointer-events: auto; margin: 0 !important; }
|
|
679
|
+
.graview-one-place-board:focus-visible { outline: 3px solid var(--graview-accent); outline-offset: 4px; border-radius: 6px; }
|
|
680
|
+
.graview-one-place-board:hover [data-graview-board-face] { border-color: var(--graview-accent); }
|
|
681
|
+
[data-graview-one-face-stops] { display: inline-flex; align-items: stretch; height: 32px; padding: 2px; gap: 2px; border-radius: 8px; border: 1px solid var(--graview-edge); background: var(--graview-panel, Canvas); box-shadow: 0 1px 2px rgba(0,0,0,0.12); box-sizing: border-box; }
|
|
682
|
+
[data-graview-one-face-stops] button { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 52px; padding: 0 10px; border: none; border-radius: 6px; background: none; color: var(--graview-ink-muted); font: inherit; font-size: 0.8125rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
|
|
683
|
+
[data-graview-one-face-stops] button:hover { color: var(--graview-ink); background: color-mix(in srgb, var(--graview-ink) 7%, transparent); }
|
|
684
|
+
[data-graview-one-face-stops] button[aria-pressed="true"] { color: var(--graview-ink); font-weight: 600; background: color-mix(in srgb, var(--graview-accent) 18%, transparent); cursor: default; }
|
|
685
|
+
[data-graview-one-face-stops] button[data-graview-key-stop] { min-width: 30px; padding: 0 8px; margin-left: 2px; box-shadow: -1px 0 0 0 var(--graview-edge); border-radius: 0 6px 6px 0; }
|
|
686
|
+
[data-graview-one-face-stops] button:focus-visible, [data-graview-one-face-slider]:focus-visible { outline: 2px solid var(--graview-accent); outline-offset: 1px; }
|
|
687
|
+
[data-graview-one-face-tip] { position: absolute; left: 0; bottom: calc(100% + 6px); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--graview-edge); background: var(--graview-panel, Canvas); color: var(--graview-ink); font-size: 0.75rem; white-space: nowrap; pointer-events: none; opacity: 0; }
|
|
688
|
+
[data-graview-one-face-tip][data-graview-shown] { opacity: 1; }
|
|
689
|
+
[data-graview-one-face-mini]:has([aria-expanded="true"]) > [data-graview-one-face-tip], [data-graview-one-face-stops]:has([data-testid="altitude-key"][aria-expanded="true"]) > [data-graview-one-face-tip] { opacity: 0; }
|
|
690
|
+
/* Put away, the same control made shorter: one row, the stops' height, border and type — the level's name, the track, and the way back to all three. */
|
|
691
|
+
[data-graview-one-face-mini] { display: inline-flex; align-items: stretch; height: 32px; padding: 2px; gap: 2px; border-radius: 8px; border: 1px solid var(--graview-edge); background: var(--graview-panel, Canvas); box-shadow: 0 1px 2px rgba(0,0,0,0.12); box-sizing: border-box; }
|
|
692
|
+
[data-graview-mini-word] { display: inline-flex; align-items: center; justify-content: center; min-width: 54px; padding: 0 4px; border: none; border-radius: 6px; background: color-mix(in srgb, var(--graview-accent) 18%, transparent); color: var(--graview-ink); font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
|
|
693
|
+
[data-graview-mini-word]:hover { background: color-mix(in srgb, var(--graview-accent) 26%, transparent); }
|
|
694
|
+
[data-graview-mini-word]:focus-visible { outline: 2px solid var(--graview-accent); outline-offset: 1px; }
|
|
695
|
+
/* The chevron: a small glyph in a 24-pixel target (a thumb's 44 on a phone), reaching over the row's own padding. */
|
|
696
|
+
[data-graview-mini-tool] { position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 24px; height: 26px; margin: 0 -2px 0 -4px; padding: 0; border: none; border-radius: 6px; background: none; color: var(--graview-ink-muted); cursor: pointer; }
|
|
697
|
+
[data-graview-mini-tool]:hover { color: var(--graview-ink); }
|
|
698
|
+
[data-graview-mini-tool]:focus-visible { outline: 2px solid var(--graview-accent); outline-offset: -2px; }
|
|
699
|
+
@media (max-width: 600px), (pointer: coarse) {
|
|
700
|
+
[data-graview-one-face-stops] { height: 48px; } [data-graview-one-face-stops] button { min-width: 64px; min-height: 44px; } [data-graview-one-face-stops] button[data-graview-key-stop] { min-width: 44px; }
|
|
701
|
+
[data-graview-one-face-mini] { height: 48px; }
|
|
702
|
+
[data-graview-mini-word] { min-width: 60px; min-height: 44px; }
|
|
703
|
+
[data-graview-mini-tool] { width: 44px; height: 44px; margin: 0; }
|
|
704
|
+
[data-testid="altitude-key-pane"] { padding-right: 48px !important; }
|
|
705
|
+
[data-testid="altitude-key-pane"] [data-testid="altitude-key-hide"] { width: 44px !important; height: 44px !important; top: 0 !important; right: 0 !important; }
|
|
706
|
+
[data-testid="altitude-keys-turn"] { min-height: 44px !important; min-width: 44px !important; }
|
|
707
|
+
}
|
|
708
|
+
`;
|
|
709
|
+
/**
|
|
710
|
+
* WHERE YOU ARE, AND THE WAY UP AND DOWN: one slim control at the window's
|
|
711
|
+
* bottom left, the bar's own size and manner — three stops, named, Page ·
|
|
712
|
+
* Nearby · City, the one you are at lit, and a press on another going
|
|
713
|
+
* there, every step drawn. Up and down are the stops either side; Alt and
|
|
714
|
+
* the arrows (and Escape, down) move one from the keyboard. Where the city
|
|
715
|
+
* is in sight, its Key is the control's last stop, opening above it. The
|
|
716
|
+
* level is said aloud as it changes.
|
|
717
|
+
*/
|
|
718
|
+
function Altitude({ box, level, moving, goTo, where, chosen, boards, current, store, motion, begin, }) {
|
|
719
|
+
/*
|
|
720
|
+
* ALL THREE LEVELS, OR ONE SLIM SLIDER. Shown whole the first time — a
|
|
721
|
+
* person learns there are three levels by reading their names — and put
|
|
722
|
+
* away into a slider naming only the level you are at whenever that is
|
|
723
|
+
* asked for, kept in this browser.
|
|
724
|
+
*/
|
|
725
|
+
const [small, setSmall] = useState(() => {
|
|
726
|
+
try {
|
|
727
|
+
return window.localStorage.getItem(CONTROL_KEY) === "slider";
|
|
728
|
+
}
|
|
729
|
+
catch {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
const keepSmall = (to) => {
|
|
734
|
+
setSmall(to);
|
|
735
|
+
try {
|
|
736
|
+
window.localStorage.setItem(CONTROL_KEY, to ? "slider" : "levels");
|
|
737
|
+
}
|
|
738
|
+
catch {
|
|
739
|
+
// A browser that keeps nothing keeps the choice for this visit.
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
useEffect(() => {
|
|
743
|
+
// A notice placed above what stands at the foot places itself again: this has changed its width.
|
|
744
|
+
if (!moving)
|
|
745
|
+
window.dispatchEvent(new Event("graview:foot-moved"));
|
|
746
|
+
}, [level, moving]);
|
|
747
|
+
const kind = where.type === "record" || where.type === "list" ? where.kind : null;
|
|
748
|
+
const into = boards.find((board) => board.key === (chosen.current ?? current));
|
|
749
|
+
/** What a press on each stop does, said. */
|
|
750
|
+
const saying = (stop) => {
|
|
751
|
+
if (stop === level)
|
|
752
|
+
return `${LEVEL_NAMES[stop]}: you are here`;
|
|
753
|
+
if (stop === PAGE)
|
|
754
|
+
return level === CITY && into && into.key !== current ? `Page: “${into.label}”, alone` : "Page: this page alone";
|
|
755
|
+
if (stop === PANEL)
|
|
756
|
+
return level === CITY ? `Nearby: ${into ? `“${into.label}”` : "this page"} beside its place in the city` : `Nearby: this page beside ${kind ? `the ${pluralOf(store, kind).toLowerCase()} district` : "the city"}`;
|
|
757
|
+
return "City: every page and view of the app";
|
|
758
|
+
};
|
|
759
|
+
/*
|
|
760
|
+
* THE LEGEND: shown by default beside the city and at the City, where it
|
|
761
|
+
* says what is on the screen, and put away there as the person chooses,
|
|
762
|
+
* kept in this browser; on the page, where there is no city to explain,
|
|
763
|
+
* only when asked for.
|
|
764
|
+
*/
|
|
765
|
+
// A phone has no room beside the city for it: there it starts put away, until it is asked for — and then it is kept.
|
|
766
|
+
const [legendCity, setLegendCity] = useState(() => {
|
|
767
|
+
const roomy = typeof window === "undefined" || window.innerWidth > PHONE;
|
|
768
|
+
try {
|
|
769
|
+
const kept = window.localStorage.getItem(LEGEND_KEY);
|
|
770
|
+
return kept === null ? roomy : kept !== "hidden";
|
|
771
|
+
}
|
|
772
|
+
catch {
|
|
773
|
+
return roomy;
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
const [legendPage, setLegendPage] = useState(false);
|
|
777
|
+
const keyOpen = level === PAGE ? legendPage : legendCity;
|
|
778
|
+
const setKeyOpen = (to) => {
|
|
779
|
+
const next = typeof to === "function" ? to(keyOpen) : to;
|
|
780
|
+
if (level === PAGE)
|
|
781
|
+
return setLegendPage(next);
|
|
782
|
+
setLegendCity(next);
|
|
783
|
+
try {
|
|
784
|
+
window.localStorage.setItem(LEGEND_KEY, next ? "shown" : "hidden");
|
|
785
|
+
}
|
|
786
|
+
catch {
|
|
787
|
+
// Kept for this visit.
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
const tipId = useId();
|
|
791
|
+
const tip = `${LEVEL_NAMES[level]} (${LEVEL_KEYS[level]}) · [ and ] to move`;
|
|
792
|
+
const intent = useIntentTip();
|
|
793
|
+
const stopTips = [PAGE, PANEL, CITY].map((stop) => intent.on(stop === level ? tip : `${LEVEL_NAMES[stop]} (${LEVEL_KEYS[stop]})`));
|
|
794
|
+
const keys = (stop) => [LEVEL_KEYS[stop], stop === level + 1 ? "] Alt+ArrowUp" : stop === level - 1 ? "[ Alt+ArrowDown Escape" : ""].filter(Boolean).join(" ");
|
|
795
|
+
return (_jsxs("div", { ref: box, role: "region", "aria-label": "Where you are", "data-testid": "altitude", "data-graview-one-face-level": level, "data-graview-foot": "", style: { position: "fixed", left: 16, right: 16, bottom: 16, zIndex: ONE_FACE_LAYERS.control, display: "flex", flexWrap: "wrap-reverse", alignItems: "flex-end", gap: 8, pointerEvents: "none" }, children: [_jsxs("div", { "data-graview-one-face-dock": "", style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: keyOpen && !small ? 30 : 8, pointerEvents: "none" }, children: [keyOpen ? _jsx(CityKey, { close: () => setKeyOpen(false) }) : null, small ? (_jsxs("div", { role: "group", "aria-label": "Level", "data-graview-one-face-mini": "", "data-graview-tip-host": "", style: { pointerEvents: "auto", position: "relative" }, children: [_jsx("button", { type: "button", "data-testid": "altitude-key", "data-graview-mini-word": "", "aria-expanded": keyOpen, "aria-label": `${LEVEL_NAMES[level]}: show the legend, what the city's marks mean and the keys`, ...intent.on("Legend"), onClick: () => setKeyOpen((open) => !open), onKeyDown: (event) => {
|
|
796
|
+
if (event.key !== "Escape" || !keyOpen)
|
|
797
|
+
return;
|
|
798
|
+
event.preventDefault();
|
|
799
|
+
event.stopPropagation();
|
|
800
|
+
setKeyOpen(false);
|
|
801
|
+
}, children: _jsx("span", { "data-testid": "altitude-mini-word", children: LEVEL_NAMES[level] }) }), _jsx(LevelSlider, { level: level, goTo: goTo, motion: motion, begin: begin, describedBy: tipId, tip: intent.on(tip) }), _jsx("button", { type: "button", "data-testid": "altitude-size", "aria-expanded": false, "aria-label": "Show all three levels", ...intent.on("Show all three levels"), onClick: () => keepSmall(false), "data-graview-mini-tool": "", children: _jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M4 3l3 3-3 3" }) }) }), _jsx(Tip, { id: tipId, tip: intent, said: tip })] })) : (_jsxs("div", { role: "group", "aria-label": `Altitude: ${LEVEL_NAMES[level].toLowerCase()}, ${level + 1} of 3`, "data-graview-one-face-stops": "", "data-graview-tip-host": "", style: { pointerEvents: "auto", position: "relative" }, children: [[PAGE, PANEL, CITY].map((stop) => (_jsxs("button", { type: "button", "data-testid": `altitude-stop-${stop}`, ...(stop === level + 1 ? { "data-graview-rise": "" } : stop === level - 1 ? { "data-graview-descend": "" } : {}), "aria-pressed": stop === level, "aria-label": saying(stop), "aria-keyshortcuts": keys(stop), ...(stop === level ? { "aria-describedby": tipId } : {}), ...stopTips[stop],
|
|
802
|
+
// The board the keyboard chose keeps it: a press here goes into it.
|
|
803
|
+
onPointerDown: (event) => {
|
|
804
|
+
event.preventDefault();
|
|
805
|
+
stopTips[stop].onPointerDown(event);
|
|
806
|
+
}, onClick: () => (stop === level ? undefined : goTo(stop)), children: [LEVEL_NAMES[stop], keyOpen ? (_jsx("kbd", { "data-testid": `altitude-keycap-${stop}`, "aria-hidden": "true", style: { position: "absolute", top: -22, left: "50%", transform: "translateX(-50%)", minWidth: 18, padding: "1px 5px", borderRadius: 4, border: "1px solid var(--graview-edge)", background: "var(--graview-panel, Canvas)", color: "var(--graview-ink)", font: "inherit", fontSize: "0.75rem", lineHeight: 1.4, textAlign: "center" }, children: LEVEL_KEYS[stop] })) : null] }, stop))), _jsx("button", { type: "button", "data-testid": "altitude-key", "data-graview-key-stop": "", "aria-expanded": keyOpen, "aria-label": "Key: what the city's marks mean", ...intent.on("Key: what the city's marks mean"), onClick: () => setKeyOpen((open) => !open), onKeyDown: (event) => {
|
|
807
|
+
// The Key's Escape is the Key's: it puts the Key away, and nothing moves a level.
|
|
808
|
+
if (event.key !== "Escape" || !keyOpen)
|
|
809
|
+
return;
|
|
810
|
+
event.preventDefault();
|
|
811
|
+
event.stopPropagation();
|
|
812
|
+
setKeyOpen(false);
|
|
813
|
+
}, children: _jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", children: [_jsx("circle", { cx: "7", cy: "7", r: "5.6" }), _jsx("path", { d: "M7 6.4v3.4" }), _jsx("circle", { cx: "7", cy: "4.3", r: "0.4", fill: "currentColor" })] }) }), _jsx(Tip, { id: tipId, tip: intent, said: tip }), _jsx("button", { type: "button", "data-testid": "altitude-size", "data-graview-key-stop": "", "aria-expanded": true, "aria-label": "Put the levels away into a slider", ...intent.on("Put the levels away into a slider"), onClick: () => keepSmall(true), children: _jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M8 3L5 6l3 3" }) }) })] }))] }), _jsx("div", { "data-graview-past-slot": "", style: { flex: "1 1 300px", minWidth: 0, maxWidth: 720, pointerEvents: "none" }, children: _jsx(PastBar, { face: "pages" }) }), _jsx("span", { role: "status", style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" }, children: moving ? "" : LEVEL_NAMES[level] })] }));
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* THE LEVELS AS A SLIDER: a short track with a stop for each level and a
|
|
817
|
+
* thumb at the one you are at, its name beside it. Dragged, the camera
|
|
818
|
+
* follows the thumb the whole way and settles at the nearest stop when it
|
|
819
|
+
* is let go, as a pinch does; pressed on the track, or moved by the arrows,
|
|
820
|
+
* Home and End, or 1, 2 and 3, it goes to a stop.
|
|
821
|
+
*/
|
|
822
|
+
/** The collapsed control's track, and its thumb. */
|
|
823
|
+
const TRACK = 64;
|
|
824
|
+
const THUMB = 14;
|
|
825
|
+
function LevelSlider({ level, goTo, motion, begin, describedBy, tip }) {
|
|
826
|
+
const track = useRef(null);
|
|
827
|
+
const moved = useRef(false);
|
|
828
|
+
const [dragging, setDragging] = useState(null);
|
|
829
|
+
const altitudeNow = () => Number(document.querySelector('[data-testid="one-place-city"]')?.getAttribute("data-graview-altitude-now") ?? level) || 0;
|
|
830
|
+
const atPointer = (clientX) => {
|
|
831
|
+
const box = track.current?.getBoundingClientRect();
|
|
832
|
+
if (!box || box.width === 0)
|
|
833
|
+
return level;
|
|
834
|
+
// The stops stand inside the track, half a thumb in from each end.
|
|
835
|
+
return Math.max(0, Math.min(CITY, ((clientX - box.left - THUMB / 2) / Math.max(1, box.width - THUMB)) * CITY));
|
|
836
|
+
};
|
|
837
|
+
const shown = dragging ?? level;
|
|
838
|
+
const named = LEVEL_NAMES[Math.round(shown)];
|
|
839
|
+
return (_jsxs("div", { role: "slider", tabIndex: 0, "data-testid": "altitude-slider", "aria-label": "Level", "aria-valuemin": PAGE, "aria-valuemax": CITY, "aria-valuenow": level, "aria-valuetext": LEVEL_NAMES[level], "aria-keyshortcuts": "1 2 3 [ ]", "aria-describedby": describedBy, onPointerEnter: tip.onPointerEnter, onPointerLeave: tip.onPointerLeave, onFocus: tip.onFocus, onBlur: tip.onBlur, onKeyDown: (event) => {
|
|
840
|
+
const to = event.key === "ArrowLeft" || event.key === "ArrowDown" ? level - 1 : event.key === "ArrowRight" || event.key === "ArrowUp" ? level + 1 : event.key === "Home" ? PAGE : event.key === "End" ? CITY : null;
|
|
841
|
+
if (to === null || event.altKey)
|
|
842
|
+
return;
|
|
843
|
+
event.preventDefault();
|
|
844
|
+
event.stopPropagation();
|
|
845
|
+
goTo(Math.max(PAGE, Math.min(CITY, to)));
|
|
846
|
+
}, onPointerDown: (event) => {
|
|
847
|
+
if (event.button !== 0 || !event.isPrimary)
|
|
848
|
+
return;
|
|
849
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
850
|
+
motion.current.held = true;
|
|
851
|
+
// Out of the page's flow and a hand on the camera from the first touch: the frame does not put the page back before the thumb moves.
|
|
852
|
+
motion.current.scrubbing = true;
|
|
853
|
+
moved.current = false;
|
|
854
|
+
begin();
|
|
855
|
+
setDragging(atPointer(event.clientX));
|
|
856
|
+
}, onPointerMove: (event) => {
|
|
857
|
+
if (dragging === null)
|
|
858
|
+
return;
|
|
859
|
+
const to = atPointer(event.clientX);
|
|
860
|
+
if (Math.abs(to - (dragging ?? to)) > 0.02)
|
|
861
|
+
moved.current = true;
|
|
862
|
+
setDragging(to);
|
|
863
|
+
// The camera follows the thumb: as far as it has gone since the last frame, as a pinch scrubs it.
|
|
864
|
+
motion.current.scrub = to - altitudeNow();
|
|
865
|
+
}, onPointerUp: (event) => {
|
|
866
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
867
|
+
const to = dragging;
|
|
868
|
+
setDragging(null);
|
|
869
|
+
motion.current.held = false;
|
|
870
|
+
// A press without a drag goes to the stop pressed; a drag settles where the camera lets it go, at the nearest.
|
|
871
|
+
if (!moved.current) {
|
|
872
|
+
motion.current.scrubbing = false;
|
|
873
|
+
motion.current.scrub = 0;
|
|
874
|
+
if (to !== null)
|
|
875
|
+
goTo(Math.round(to));
|
|
876
|
+
}
|
|
877
|
+
}, onPointerCancel: () => {
|
|
878
|
+
setDragging(null);
|
|
879
|
+
motion.current.held = false;
|
|
880
|
+
motion.current.scrub = 0;
|
|
881
|
+
}, "data-graview-one-face-slider": "", style: { position: "relative", flex: "none", display: "inline-flex", alignItems: "center", width: TRACK, padding: 0, cursor: "pointer", touchAction: "none", outline: "none", borderRadius: 6 }, children: [_jsxs("div", { ref: track, "aria-hidden": "true", style: { position: "relative", width: "100%", height: 2, borderRadius: 1, background: "var(--graview-edge)" }, children: [[PAGE, PANEL, CITY].map((stop) => (_jsx("span", { style: { position: "absolute", left: `calc(${THUMB / 2}px + ${stop / CITY} * (100% - ${THUMB}px))`, top: "50%", width: 2, height: 8, marginLeft: -1, marginTop: -4, borderRadius: 1, background: "var(--graview-ink-muted)" } }, stop))), _jsx("span", { "data-testid": "altitude-thumb", style: { position: "absolute", left: `calc(${THUMB / 2}px + ${shown / CITY} * (100% - ${THUMB}px))`, top: "50%", width: THUMB, height: THUMB, marginLeft: -THUMB / 2, marginTop: -THUMB / 2, borderRadius: THUMB / 2, background: "var(--graview-accent)", boxShadow: "0 1px 3px rgba(0,0,0,0.3)", transition: dragging === null ? "left 200ms ease" : "none" } })] }), _jsx("span", { "data-testid": "altitude-word", "aria-hidden": "true", style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: named })] }));
|
|
882
|
+
}
|
|
883
|
+
/** What on a page a person reads or presses: a part that would be covered if the control stood over it. */
|
|
884
|
+
const CONTENT = "a[href], button, input, select, textarea, img, svg, video, canvas, [role=button], [role=link]";
|
|
885
|
+
/**
|
|
886
|
+
* THE ROOM THE PAGE KEEPS AT ITS FOOT FOR THE CONTROL — only as much as
|
|
887
|
+
* keeps the control off the page's content when it is scrolled to its end.
|
|
888
|
+
* Every part with words or a control whose column the control stands in
|
|
889
|
+
* (the control's width, and a little air) is measured where it would be at
|
|
890
|
+
* the scroll's end: the room is what lifts the lowest of them clear of the
|
|
891
|
+
* control's top. A footer whose words stand at its right, the control at
|
|
892
|
+
* its empty left, keeps no room at all.
|
|
893
|
+
*/
|
|
894
|
+
function FootRoom({ fab, sheet }) {
|
|
895
|
+
const room = useRef(null);
|
|
896
|
+
const [height, setHeight] = useState(0);
|
|
897
|
+
useEffect(() => {
|
|
898
|
+
let frame = 0;
|
|
899
|
+
const measure = () => {
|
|
900
|
+
frame = 0;
|
|
901
|
+
const plane = sheet.current;
|
|
902
|
+
const holder = fab.current;
|
|
903
|
+
const spacer = room.current;
|
|
904
|
+
if (!plane || !holder || !spacer)
|
|
905
|
+
return;
|
|
906
|
+
const parts = [holder.querySelector("[data-graview-one-face-dock]"), holder.querySelector("[data-graview-past-slot] > *")].flatMap((el) => {
|
|
907
|
+
const r = el?.getBoundingClientRect();
|
|
908
|
+
return r && r.width > 0 && r.height > 0 ? [r] : [];
|
|
909
|
+
});
|
|
910
|
+
if (parts.length === 0)
|
|
911
|
+
return setHeight(0);
|
|
912
|
+
const scrollY = window.scrollY;
|
|
913
|
+
const whole = document.documentElement.scrollHeight - spacer.offsetHeight;
|
|
914
|
+
const end = Math.max(0, whole - window.innerHeight);
|
|
915
|
+
let lowest = -Infinity;
|
|
916
|
+
for (const el of plane.querySelectorAll("*")) {
|
|
917
|
+
if (el === spacer || spacer.contains(el))
|
|
918
|
+
continue;
|
|
919
|
+
// A leaf with words, or a control or a picture: what a person reads or presses.
|
|
920
|
+
const said = el.matches(CONTENT) || (el.childElementCount === 0 && (el.textContent ?? "").trim().length > 0);
|
|
921
|
+
if (!said)
|
|
922
|
+
continue;
|
|
923
|
+
const r = el.getBoundingClientRect();
|
|
924
|
+
if (r.width === 0 || r.height === 0)
|
|
925
|
+
continue;
|
|
926
|
+
if (r.bottom + scrollY < end + window.innerHeight - 400)
|
|
927
|
+
continue;
|
|
928
|
+
if (!parts.some((part) => r.right > part.left - 8 && r.left < part.right + 8))
|
|
929
|
+
continue;
|
|
930
|
+
// Fixed to the window (a notice, a dialog): it does not scroll to the page's end.
|
|
931
|
+
if (el.offsetParent === null && getComputedStyle(el).position === "fixed")
|
|
932
|
+
continue;
|
|
933
|
+
// Inside a box that scrolls or clips: where that box shows it, not where its content runs on below.
|
|
934
|
+
let seen = r.bottom;
|
|
935
|
+
for (let at = el.parentElement; at && at !== plane; at = at.parentElement) {
|
|
936
|
+
const style = getComputedStyle(at);
|
|
937
|
+
if (style.position === "fixed") {
|
|
938
|
+
seen = -Infinity;
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
if (style.overflowY !== "visible")
|
|
942
|
+
seen = Math.min(seen, at.getBoundingClientRect().bottom);
|
|
943
|
+
}
|
|
944
|
+
if (seen === -Infinity)
|
|
945
|
+
continue;
|
|
946
|
+
lowest = Math.max(lowest, seen + scrollY);
|
|
947
|
+
}
|
|
948
|
+
if (lowest === -Infinity)
|
|
949
|
+
return setHeight(0);
|
|
950
|
+
// The control's top where it rests, and air above it: the lowest such part ends there at the scroll's end.
|
|
951
|
+
const top = Math.min(...parts.map((part) => part.top)) - 8;
|
|
952
|
+
const need = Math.ceil(lowest - top + window.innerHeight - whole);
|
|
953
|
+
setHeight((was) => (Math.abs(was - Math.max(0, need)) < 1 ? was : Math.max(0, need)));
|
|
954
|
+
};
|
|
955
|
+
const soon = () => {
|
|
956
|
+
if (!frame)
|
|
957
|
+
frame = requestAnimationFrame(measure);
|
|
958
|
+
};
|
|
959
|
+
soon();
|
|
960
|
+
const sized = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(soon);
|
|
961
|
+
// The page is in the window's flow here (its box is the document's): the body's size is the page's.
|
|
962
|
+
sized?.observe(document.body);
|
|
963
|
+
if (fab.current)
|
|
964
|
+
sized?.observe(fab.current);
|
|
965
|
+
const changed = typeof MutationObserver === "undefined" ? null : new MutationObserver(soon);
|
|
966
|
+
if (sheet.current)
|
|
967
|
+
changed?.observe(sheet.current, { childList: true, subtree: true, characterData: true });
|
|
968
|
+
window.addEventListener("resize", soon);
|
|
969
|
+
return () => {
|
|
970
|
+
cancelAnimationFrame(frame);
|
|
971
|
+
sized?.disconnect();
|
|
972
|
+
changed?.disconnect();
|
|
973
|
+
window.removeEventListener("resize", soon);
|
|
974
|
+
};
|
|
975
|
+
}, [fab, sheet]);
|
|
976
|
+
return _jsx("div", { ref: room, "aria-hidden": "true", "data-graview-altitude-room": "", style: { height } });
|
|
977
|
+
}
|
|
978
|
+
/** The level's keys, said as they are now, with the one button that turns them off or back on (WCAG 2.1.4). A bare checkbox read as "off" while the keys worked; the line itself says which it is. */
|
|
979
|
+
function KeysLine() {
|
|
980
|
+
const [on, setOn] = useState(keysOn);
|
|
981
|
+
const turn = () => {
|
|
982
|
+
const next = !on;
|
|
983
|
+
setOn(next);
|
|
984
|
+
try {
|
|
985
|
+
window.localStorage.setItem(KEYS_KEY, next ? "on" : "off");
|
|
986
|
+
}
|
|
987
|
+
catch {
|
|
988
|
+
// Kept for this visit only.
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
const button = (_jsx("button", { type: "button", "data-testid": "altitude-keys-turn", "aria-pressed": on, "aria-label": on ? "Level keys are on: turn them off" : "Level keys are off: turn them on", onClick: turn, style: { display: "inline-flex", alignItems: "center", minHeight: 24, minWidth: 24, marginLeft: 6, padding: "0 4px", verticalAlign: "middle", border: "none", background: "none", color: "var(--graview-accent)", font: "inherit", textDecoration: "underline", textUnderlineOffset: 2, cursor: "pointer" }, children: on ? "Turn off" : "Turn on" }));
|
|
992
|
+
return (_jsxs("p", { "data-testid": "altitude-key-keys", "data-graview-keys": on ? "on" : "off", style: { margin: "0 0 6px", color: "var(--graview-ink-muted)" }, children: [_jsx("strong", { style: { fontWeight: 600, color: "var(--graview-ink)" }, children: "Keys" }), on ? ": 1 Page · 2 Nearby · 3 City · [ down · ] up" : " are off: Alt ↑ up · Alt ↓ down", button] }));
|
|
993
|
+
}
|
|
994
|
+
/** What the city's marks mean, as this face draws them: nothing it does not draw. */
|
|
995
|
+
function CityKey({ close }) {
|
|
996
|
+
const swatch = (inner) => _jsx("span", { "aria-hidden": "true", style: { display: "inline-flex", width: 18, height: 14, alignItems: "center", justifyContent: "center" }, children: inner });
|
|
997
|
+
const rows = [
|
|
998
|
+
[swatch(_jsx("span", { style: { width: 14, height: 10, borderRadius: 2, border: "1.5px solid var(--graview-edge)", borderTopWidth: 3, borderTopColor: "var(--graview-accent)", background: "var(--graview-ground)" } })), "View", "a page of the app. Click to open it."],
|
|
999
|
+
[swatch(_jsx("svg", { width: "18", height: "12", viewBox: "0 0 18 12", children: _jsx("path", { d: "M9 1 17 6 9 11 1 6Z", fill: "none", stroke: "var(--graview-edge)", strokeWidth: "1.4" }) })), "District", "all the records of one kind."],
|
|
1000
|
+
[swatch(_jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", children: [_jsx("path", { d: "M7 1 13 4 7 7 1 4Z", fill: "color-mix(in srgb, var(--graview-ink) 30%, var(--graview-panel))" }), _jsx("path", { d: "M1 4v6l6 3V7Z", fill: "color-mix(in srgb, var(--graview-ink) 18%, var(--graview-panel))" }), _jsx("path", { d: "M13 4v6l-6 3V7Z", fill: "color-mix(in srgb, var(--graview-ink) 24%, var(--graview-panel))" })] })), "Building", "one record."],
|
|
1001
|
+
[swatch(_jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", children: [_jsx("path", { d: "M7 1 13 4 7 7 1 4Z", fill: "var(--graview-warn)" }), _jsx("path", { d: "M1 4v6l6 3V7Z", fill: "color-mix(in srgb, var(--graview-warn) 70%, black)" }), _jsx("path", { d: "M13 4v6l-6 3V7Z", fill: "color-mix(in srgb, var(--graview-warn) 85%, black)" })] })), "Orange roof", "needs your attention."],
|
|
1002
|
+
[swatch(_jsx("svg", { width: "18", height: "12", viewBox: "0 0 18 12", children: _jsx("path", { d: "M1 11 Q9 1 17 6", fill: "none", stroke: "var(--graview-accent)", strokeWidth: "1.5" }) })), "Line", "links something on the page to its record."],
|
|
1003
|
+
[swatch(_jsx("span", { style: { width: 18, height: 3, borderRadius: 2, background: "var(--graview-edge)" } })), "Road", "these kinds are linked."],
|
|
1004
|
+
];
|
|
1005
|
+
return (_jsxs("div", { role: "region", "aria-label": "What the city's marks mean", "data-testid": "altitude-key-pane", onKeyDown: (event) => {
|
|
1006
|
+
if (event.key !== "Escape")
|
|
1007
|
+
return;
|
|
1008
|
+
event.preventDefault();
|
|
1009
|
+
event.stopPropagation();
|
|
1010
|
+
close();
|
|
1011
|
+
}, style: { pointerEvents: "auto", position: "relative", width: "max-content", maxWidth: "calc(100vw - 32px)", padding: "8px 28px 8px 10px", borderRadius: 8, border: "1px solid var(--graview-edge)", background: "var(--graview-panel, Canvas)", color: "var(--graview-ink)", boxShadow: "0 1px 2px rgba(0,0,0,0.12)", fontSize: "0.75rem", lineHeight: 1.35 }, children: [_jsx("button", { type: "button", "data-testid": "altitude-key-hide", "aria-label": "Put the legend away", onClick: close, style: { position: "absolute", top: 2, right: 2, width: 24, height: 24, padding: 0, border: "none", borderRadius: 4, background: "none", color: "var(--graview-ink-muted)", font: "inherit", cursor: "pointer" }, children: "\u00D7" }), _jsx(KeysLine, {}), _jsx("ul", { style: { listStyle: "none", margin: 0, padding: 0, display: "grid", gap: 3 }, children: rows.map(([mark, term, words]) => (_jsxs("li", { style: { display: "grid", gridTemplateColumns: "18px 1fr", gap: 10, alignItems: "start", lineHeight: "18px" }, children: [_jsx("span", { style: { display: "flex", height: 18, alignItems: "center" }, children: mark }), _jsxs("span", { children: [_jsx("strong", { style: { fontWeight: 600 }, children: term }), ": ", words] })] }, term))) })] }));
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* CONNECTED: what the record is linked to that its page does not already
|
|
1015
|
+
* show — a relation the page draws as a section of its own is not said
|
|
1016
|
+
* again — at the page's foot, in its flow, never over its words. Grown in
|
|
1017
|
+
* as the page becomes the panel (its box's height is set each frame); each
|
|
1018
|
+
* row is the record it names, and a line leaves the page's edge level with
|
|
1019
|
+
* it for that record's building. Nothing at all when the page shows every
|
|
1020
|
+
* one. What the Scene's own record view said under the record ("why this is
|
|
1021
|
+
* here", "the list it is on") is here when the page does not say it.
|
|
1022
|
+
*/
|
|
1023
|
+
function Connected({ store, id, box, sheet, openRecord }) {
|
|
1024
|
+
const tick = useStoreTick(store);
|
|
1025
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1026
|
+
const facts = useMemo(() => recordFacts(store, id), [store, id, tick]);
|
|
1027
|
+
/* What the page shows already: every record a part of it marks, outside this list. */
|
|
1028
|
+
const [onPage, setOnPage] = useState(null);
|
|
1029
|
+
useLayoutEffect(() => {
|
|
1030
|
+
const plane = sheet.current;
|
|
1031
|
+
if (!plane)
|
|
1032
|
+
return;
|
|
1033
|
+
const read = () => {
|
|
1034
|
+
const shown = new Set();
|
|
1035
|
+
for (const part of plane.querySelectorAll("[data-graview-pick], [data-graview-record], [data-record], a[href]")) {
|
|
1036
|
+
if (box.current?.contains(part))
|
|
1037
|
+
continue;
|
|
1038
|
+
const marked = part.getAttribute("data-graview-pick") ?? part.getAttribute("data-graview-record") ?? part.getAttribute("data-record");
|
|
1039
|
+
if (marked)
|
|
1040
|
+
shown.add(marked);
|
|
1041
|
+
else if (part instanceof HTMLAnchorElement) {
|
|
1042
|
+
if (part.origin !== window.location.origin)
|
|
1043
|
+
continue;
|
|
1044
|
+
try {
|
|
1045
|
+
const last = decodeURIComponent(part.pathname.split("/").filter(Boolean).at(-1) ?? "");
|
|
1046
|
+
if (last)
|
|
1047
|
+
shown.add(last);
|
|
1048
|
+
}
|
|
1049
|
+
catch {
|
|
1050
|
+
// An address that is no record's.
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
setOnPage((was) => (was && was.size === shown.size && [...shown].every((one) => was.has(one)) ? was : shown));
|
|
1055
|
+
};
|
|
1056
|
+
read();
|
|
1057
|
+
const watch = typeof MutationObserver === "undefined" ? null : new MutationObserver(read);
|
|
1058
|
+
watch?.observe(plane, { childList: true, subtree: true });
|
|
1059
|
+
return () => watch?.disconnect();
|
|
1060
|
+
}, [sheet, box, id, tick]);
|
|
1061
|
+
const groups = (facts?.links ?? []).map((group) => ({ ...group, targets: group.targets.filter((target) => !onPage?.has(target.id)) })).filter((group) => group.targets.length > 0);
|
|
1062
|
+
const total = groups.reduce((sum, group) => sum + group.targets.length, 0);
|
|
1063
|
+
if (onPage === null || total === 0)
|
|
1064
|
+
return _jsx("div", { ref: box, "data-graview-connected-box": "", hidden: true });
|
|
1065
|
+
return (_jsx("div", { ref: box, "data-graview-connected-box": "", style: { height: 0, opacity: 0, overflow: "hidden", background: "var(--graview-panel, Canvas)", borderTop: "1px solid var(--graview-edge)", flex: "0 0 auto" }, children: _jsxs("section", { "data-graview-connected": total, "aria-label": "Also connected", style: { padding: "10px 18px 12px" }, children: [_jsxs("h2", { style: { margin: "0 0 6px", fontSize: "0.95rem" }, children: ["Also connected ", _jsxs("span", { style: { fontWeight: 400, color: "var(--graview-ink-faint)" }, children: ["\u00B7 ", total] })] }), groups.map((group) => (_jsxs("div", { style: { marginTop: 6 }, children: [_jsx("div", { style: { fontSize: "0.75rem", color: "var(--graview-ink-muted)" }, children: group.description ?? group.edgeKind }), _jsx("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, children: group.targets.map((target) => (_jsx("li", { children: _jsx("button", { type: "button", "data-graview-record": target.id, onClick: () => openRecord(target.id, PANEL), style: { display: "block", width: "100%", textAlign: "start", padding: "4px 0", border: "none", background: "none", color: "var(--graview-ink)", font: "inherit", fontSize: "0.9rem", cursor: "pointer", minHeight: 32 }, children: target.label }) }, target.id))) })] }, `${group.edgeKind}|${group.direction}`)))] }) }));
|
|
1066
|
+
}
|
|
1067
|
+
export { PHONE };
|
|
1068
|
+
/**
|
|
1069
|
+
* THE PANEL'S INNER EDGE, TO DRAG: a desk's panel wider or narrower by its
|
|
1070
|
+
* left edge, a phone's sheet higher or lower by its top. A separator the
|
|
1071
|
+
* keyboard reaches: the arrows step it, Home and End go to its least and
|
|
1072
|
+
* most, a double press puts it back. The city beside it follows on the one
|
|
1073
|
+
* camera as it moves (`one-place-city.tsx`).
|
|
1074
|
+
*/
|
|
1075
|
+
function PanelEdge({ view, size, keep, motion }) {
|
|
1076
|
+
const phone = view.width <= PHONE;
|
|
1077
|
+
const range = panelRange(view);
|
|
1078
|
+
const panel = panelBox(view);
|
|
1079
|
+
const now = view.panel ?? range.default;
|
|
1080
|
+
const clamp = (value) => Math.max(range.min, Math.min(range.max, value));
|
|
1081
|
+
const bar = view.top ?? 0;
|
|
1082
|
+
const fromPointer = (event) => (phone ? (event.clientY - bar) / Math.max(1, view.height - bar) : view.width - 12 - event.clientX);
|
|
1083
|
+
const step = phone ? 0.04 : 24;
|
|
1084
|
+
const said = phone ? `${Math.round((1 - now) * 100)}% of the window` : `${Math.round(now)} pixels wide`;
|
|
1085
|
+
return (_jsx("div", { role: "separator", "aria-orientation": phone ? "horizontal" : "vertical", "aria-label": phone ? "The sheet's height" : "The panel's width", "aria-valuenow": Math.round(phone ? (1 - now) * 100 : now), "aria-valuemin": Math.round(phone ? (1 - range.max) * 100 : range.min), "aria-valuemax": Math.round(phone ? (1 - range.min) * 100 : range.max), "aria-valuetext": said, tabIndex: 0, "data-testid": "one-place-panel-edge", title: "Drag to size the panel; double-click to put it back", onPointerDown: (event) => {
|
|
1086
|
+
event.preventDefault();
|
|
1087
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1088
|
+
motion.current.resizing = true;
|
|
1089
|
+
}, onPointerMove: (event) => {
|
|
1090
|
+
if (!motion.current.resizing)
|
|
1091
|
+
return;
|
|
1092
|
+
size(clamp(fromPointer(event)));
|
|
1093
|
+
}, onPointerUp: (event) => {
|
|
1094
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
1095
|
+
motion.current.resizing = false;
|
|
1096
|
+
keep();
|
|
1097
|
+
}, onPointerCancel: () => {
|
|
1098
|
+
motion.current.resizing = false;
|
|
1099
|
+
}, onDoubleClick: () => {
|
|
1100
|
+
size(undefined);
|
|
1101
|
+
requestAnimationFrame(keep);
|
|
1102
|
+
}, onKeyDown: (event) => {
|
|
1103
|
+
// A phone's sheet grows as its top goes up: the share above it shrinks.
|
|
1104
|
+
const grow = phone ? -step : step;
|
|
1105
|
+
const to = event.key === "Home" ? (phone ? range.max : range.min) : event.key === "End" ? (phone ? range.min : range.max) : event.key === (phone ? "ArrowUp" : "ArrowLeft") ? now + grow : event.key === (phone ? "ArrowDown" : "ArrowRight") ? now - grow : null;
|
|
1106
|
+
if (to === null)
|
|
1107
|
+
return;
|
|
1108
|
+
event.preventDefault();
|
|
1109
|
+
size(clamp(to));
|
|
1110
|
+
requestAnimationFrame(keep);
|
|
1111
|
+
}, className: "graview-one-place-edge", style: phone
|
|
1112
|
+
? { position: "fixed", left: panel.x + panel.width / 2 - 32, top: panel.y - 14, width: 64, height: 28, zIndex: ONE_FACE_LAYERS.edge, cursor: "row-resize", touchAction: "none" }
|
|
1113
|
+
: { position: "fixed", left: panel.x - 8, top: panel.y + 16, width: 14, height: panel.height - 32, zIndex: ONE_FACE_LAYERS.edge, cursor: "col-resize", touchAction: "none" } }));
|
|
1114
|
+
}
|
|
1115
|
+
//# sourceMappingURL=one-place.js.map
|