@particle-academy/fancy-3d 0.6.0 → 0.7.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/AGENTS.md +1 -0
- package/CHANGELOG.md +42 -0
- package/README.md +1 -0
- package/dist/canvas/index.cjs +13 -750
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +14 -2
- package/dist/canvas/index.d.ts +14 -2
- package/dist/canvas/index.js +2 -1
- package/dist/{chunk-F3HZDJSN.js → chunk-25GMZVYQ.js} +23 -143
- package/dist/chunk-25GMZVYQ.js.map +1 -0
- package/dist/chunk-IU7B7Y63.cjs +694 -0
- package/dist/chunk-IU7B7Y63.cjs.map +1 -0
- package/dist/chunk-PBKOUAUY.cjs +319 -0
- package/dist/chunk-PBKOUAUY.cjs.map +1 -0
- package/dist/chunk-UOFTGHV6.js +312 -0
- package/dist/chunk-UOFTGHV6.js.map +1 -0
- package/dist/fullscreen.cjs +32 -0
- package/dist/fullscreen.cjs.map +1 -0
- package/dist/fullscreen.d.cts +85 -0
- package/dist/fullscreen.d.ts +85 -0
- package/dist/fullscreen.js +3 -0
- package/dist/fullscreen.js.map +1 -0
- package/dist/index.cjs +75 -808
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/docs/Canvas.md +5 -0
- package/docs/fullscreen.md +98 -0
- package/package.json +14 -1
- package/dist/chunk-F3HZDJSN.js.map +0 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { createContext, useContext, useState, useRef, useCallback, useLayoutEffect, useEffect } from 'react';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/fullscreen.tsx
|
|
5
|
+
var DEFAULT_FULLSCREEN_LABELS = { enter: "Enter full screen", exit: "Exit full screen" };
|
|
6
|
+
var FullscreenContext = createContext(null);
|
|
7
|
+
function useFullscreenContext() {
|
|
8
|
+
return useContext(FullscreenContext);
|
|
9
|
+
}
|
|
10
|
+
function fullscreenElement() {
|
|
11
|
+
if (typeof document === "undefined") return null;
|
|
12
|
+
const d = document;
|
|
13
|
+
return d.fullscreenElement ?? d.webkitFullscreenElement ?? null;
|
|
14
|
+
}
|
|
15
|
+
function nativeFullscreenSupported(el) {
|
|
16
|
+
if (typeof document === "undefined") return false;
|
|
17
|
+
const d = document;
|
|
18
|
+
const enabled = d.fullscreenEnabled ?? d.webkitFullscreenEnabled;
|
|
19
|
+
if (enabled === false || enabled === void 0) return false;
|
|
20
|
+
const target = el ?? document.documentElement;
|
|
21
|
+
return typeof target.requestFullscreen === "function" || typeof target.webkitRequestFullscreen === "function";
|
|
22
|
+
}
|
|
23
|
+
function requestNative(el) {
|
|
24
|
+
const e = el;
|
|
25
|
+
try {
|
|
26
|
+
if (typeof e.requestFullscreen === "function") return Promise.resolve(e.requestFullscreen());
|
|
27
|
+
if (typeof e.webkitRequestFullscreen === "function") {
|
|
28
|
+
e.webkitRequestFullscreen();
|
|
29
|
+
return Promise.resolve();
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
return Promise.reject(err);
|
|
33
|
+
}
|
|
34
|
+
return Promise.reject(new Error("no Fullscreen API"));
|
|
35
|
+
}
|
|
36
|
+
function exitNative() {
|
|
37
|
+
const d = document;
|
|
38
|
+
try {
|
|
39
|
+
if (typeof d.exitFullscreen === "function") Promise.resolve(d.exitFullscreen()).catch(() => {
|
|
40
|
+
});
|
|
41
|
+
else d.webkitExitFullscreen?.();
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
var EXPANDED = [
|
|
46
|
+
["position", "fixed"],
|
|
47
|
+
["top", "0px"],
|
|
48
|
+
["right", "0px"],
|
|
49
|
+
["bottom", "0px"],
|
|
50
|
+
["left", "0px"],
|
|
51
|
+
["width", "100%"],
|
|
52
|
+
["height", "100%"],
|
|
53
|
+
["maxWidth", "none"],
|
|
54
|
+
["maxHeight", "none"],
|
|
55
|
+
["margin", "0px"],
|
|
56
|
+
["borderRadius", "0px"],
|
|
57
|
+
["boxSizing", "border-box"]
|
|
58
|
+
];
|
|
59
|
+
function isTransparent(color) {
|
|
60
|
+
if (!color || color === "transparent") return true;
|
|
61
|
+
const m = /rgba?\(([^)]+)\)/.exec(color);
|
|
62
|
+
if (!m) return false;
|
|
63
|
+
const parts = m[1].split(/[\s,/]+/).filter(Boolean);
|
|
64
|
+
return parts.length === 4 && Number.parseFloat(parts[3]) === 0;
|
|
65
|
+
}
|
|
66
|
+
function surfaceBehind(el) {
|
|
67
|
+
for (let p = el.parentElement; p; p = p.parentElement) {
|
|
68
|
+
const c = getComputedStyle(p).backgroundColor;
|
|
69
|
+
if (!isTransparent(c)) return c;
|
|
70
|
+
}
|
|
71
|
+
return "rgb(255, 255, 255)";
|
|
72
|
+
}
|
|
73
|
+
var FOCUS_TARGET = "canvas[tabindex], [tabindex='0'], button:not([disabled])";
|
|
74
|
+
function useFullscreen(ref, options = {}) {
|
|
75
|
+
const { fullscreen: controlled, defaultFullscreen = false, onFullscreenChange, mode: modeOption = "auto", closeOnEscape = true, zIndex = 50, enabled = true } = options;
|
|
76
|
+
const labels = { ...DEFAULT_FULLSCREEN_LABELS, ...options.labels ?? {} };
|
|
77
|
+
const [inner, setInner] = useState(defaultFullscreen);
|
|
78
|
+
const fullscreen = controlled ?? inner;
|
|
79
|
+
const [mode, setMode] = useState(null);
|
|
80
|
+
const [nativeSupported, setNativeSupported] = useState(false);
|
|
81
|
+
const actual = useRef(null);
|
|
82
|
+
const requested = useRef(fullscreen);
|
|
83
|
+
requested.current = fullscreen;
|
|
84
|
+
const latest = useRef({ controlled, onFullscreenChange, modeOption, closeOnEscape, zIndex });
|
|
85
|
+
latest.current = { controlled, onFullscreenChange, modeOption, closeOnEscape, zIndex };
|
|
86
|
+
const saved = useRef(null);
|
|
87
|
+
const focusMemo = useRef(null);
|
|
88
|
+
const setFullscreen = useCallback((on, meta) => {
|
|
89
|
+
if (requested.current === on) return;
|
|
90
|
+
const source = meta?.source ?? "api";
|
|
91
|
+
requested.current = on;
|
|
92
|
+
if (latest.current.controlled === void 0) setInner(on);
|
|
93
|
+
latest.current.onFullscreenChange?.(on, { source });
|
|
94
|
+
}, []);
|
|
95
|
+
const toggle = useCallback((meta) => setFullscreen(!requested.current, { source: meta?.source ?? "user" }), [setFullscreen]);
|
|
96
|
+
const rememberFocus = (el) => {
|
|
97
|
+
const active = document.activeElement;
|
|
98
|
+
focusMemo.current = active instanceof HTMLElement && el.contains(active) ? active : null;
|
|
99
|
+
};
|
|
100
|
+
const restoreFocus = (el, entering) => {
|
|
101
|
+
const memo = focusMemo.current;
|
|
102
|
+
if (memo?.isConnected) {
|
|
103
|
+
if (document.activeElement !== memo) memo.focus({ preventScroll: true });
|
|
104
|
+
} else if (entering && !el.contains(document.activeElement)) {
|
|
105
|
+
el.querySelector(FOCUS_TARGET)?.focus({ preventScroll: true });
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const notifyResize = () => {
|
|
109
|
+
if (typeof window === "undefined") return;
|
|
110
|
+
const fire = () => window.dispatchEvent(new Event("resize"));
|
|
111
|
+
if (typeof requestAnimationFrame === "function") requestAnimationFrame(fire);
|
|
112
|
+
else fire();
|
|
113
|
+
};
|
|
114
|
+
const expand = (el) => {
|
|
115
|
+
if (!saved.current) {
|
|
116
|
+
saved.current = {
|
|
117
|
+
style: [...EXPANDED.map(([k]) => k), "zIndex"].map((k) => [k, el.style[k]]),
|
|
118
|
+
pageOverflow: document.documentElement.style.overflow
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const s = el.style;
|
|
122
|
+
for (const [k, v] of EXPANDED) s[k] = v;
|
|
123
|
+
s.zIndex = String(latest.current.zIndex);
|
|
124
|
+
document.documentElement.style.overflow = "hidden";
|
|
125
|
+
actual.current = "expanded";
|
|
126
|
+
el.setAttribute("data-fancy-3d-fullscreen-mode", "expanded");
|
|
127
|
+
setMode("expanded");
|
|
128
|
+
restoreFocus(el, true);
|
|
129
|
+
notifyResize();
|
|
130
|
+
};
|
|
131
|
+
const collapse = (el) => {
|
|
132
|
+
const memo = saved.current;
|
|
133
|
+
if (memo) {
|
|
134
|
+
const s = el.style;
|
|
135
|
+
for (const [k, v] of memo.style) s[k] = v;
|
|
136
|
+
document.documentElement.style.overflow = memo.pageOverflow;
|
|
137
|
+
saved.current = null;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const backdrop = useRef(null);
|
|
141
|
+
const applyBackdrop = (el) => {
|
|
142
|
+
if (backdrop.current !== null || !isTransparent(getComputedStyle(el).backgroundColor)) return;
|
|
143
|
+
backdrop.current = el.style.backgroundColor;
|
|
144
|
+
el.style.backgroundColor = surfaceBehind(el);
|
|
145
|
+
};
|
|
146
|
+
const restoreBackdrop = (el) => {
|
|
147
|
+
if (backdrop.current === null) return;
|
|
148
|
+
el.style.backgroundColor = backdrop.current;
|
|
149
|
+
backdrop.current = null;
|
|
150
|
+
};
|
|
151
|
+
const enterDom = (el) => {
|
|
152
|
+
if (actual.current !== null) return;
|
|
153
|
+
rememberFocus(el);
|
|
154
|
+
el.setAttribute("data-fancy-3d-fullscreen", "true");
|
|
155
|
+
applyBackdrop(el);
|
|
156
|
+
if (latest.current.modeOption === "auto" && nativeFullscreenSupported(el)) {
|
|
157
|
+
actual.current = "pending";
|
|
158
|
+
requestNative(el).then(
|
|
159
|
+
() => {
|
|
160
|
+
if (actual.current === "pending" && fullscreenElement() === el) settleNative(el);
|
|
161
|
+
},
|
|
162
|
+
() => {
|
|
163
|
+
if (actual.current === "pending" && requested.current) expand(el);
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
} else {
|
|
167
|
+
expand(el);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const settleNative = (el) => {
|
|
171
|
+
actual.current = "native";
|
|
172
|
+
el.setAttribute("data-fancy-3d-fullscreen-mode", "native");
|
|
173
|
+
setMode("native");
|
|
174
|
+
restoreFocus(el, true);
|
|
175
|
+
};
|
|
176
|
+
const leaveDom = (el) => {
|
|
177
|
+
const was = actual.current;
|
|
178
|
+
if (was === null) return;
|
|
179
|
+
rememberFocus(el);
|
|
180
|
+
actual.current = null;
|
|
181
|
+
if (was === "native" || was === "pending") {
|
|
182
|
+
if (fullscreenElement() === el) exitNative();
|
|
183
|
+
}
|
|
184
|
+
collapse(el);
|
|
185
|
+
restoreBackdrop(el);
|
|
186
|
+
el.setAttribute("data-fancy-3d-fullscreen", "false");
|
|
187
|
+
el.removeAttribute("data-fancy-3d-fullscreen-mode");
|
|
188
|
+
setMode(null);
|
|
189
|
+
restoreFocus(el, false);
|
|
190
|
+
notifyResize();
|
|
191
|
+
};
|
|
192
|
+
useLayoutEffect(() => {
|
|
193
|
+
const el = ref.current;
|
|
194
|
+
if (!el || !enabled) return;
|
|
195
|
+
if (!el.hasAttribute("data-fancy-3d-fullscreen")) el.setAttribute("data-fancy-3d-fullscreen", "false");
|
|
196
|
+
setNativeSupported(nativeFullscreenSupported(el));
|
|
197
|
+
const onChange = () => {
|
|
198
|
+
const now = fullscreenElement();
|
|
199
|
+
if (now === el) {
|
|
200
|
+
if (actual.current === "pending") settleNative(el);
|
|
201
|
+
else if (actual.current === null) exitNative();
|
|
202
|
+
} else if (actual.current === "native") {
|
|
203
|
+
actual.current = null;
|
|
204
|
+
restoreBackdrop(el);
|
|
205
|
+
el.setAttribute("data-fancy-3d-fullscreen", "false");
|
|
206
|
+
el.removeAttribute("data-fancy-3d-fullscreen-mode");
|
|
207
|
+
setMode(null);
|
|
208
|
+
setFullscreen(false, { source: "browser" });
|
|
209
|
+
restoreFocus(el, false);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
document.addEventListener("fullscreenchange", onChange);
|
|
213
|
+
document.addEventListener("webkitfullscreenchange", onChange);
|
|
214
|
+
return () => {
|
|
215
|
+
document.removeEventListener("fullscreenchange", onChange);
|
|
216
|
+
document.removeEventListener("webkitfullscreenchange", onChange);
|
|
217
|
+
leaveDom(el);
|
|
218
|
+
};
|
|
219
|
+
}, [enabled]);
|
|
220
|
+
useLayoutEffect(() => {
|
|
221
|
+
const el = ref.current;
|
|
222
|
+
if (!el || !enabled) return;
|
|
223
|
+
if (fullscreen) enterDom(el);
|
|
224
|
+
else leaveDom(el);
|
|
225
|
+
}, [fullscreen, enabled]);
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (mode !== "expanded") return;
|
|
228
|
+
const onKey = (e) => {
|
|
229
|
+
if (e.key !== "Escape" || e.isComposing || !latest.current.closeOnEscape) return;
|
|
230
|
+
const target = e.target instanceof Element ? e.target : null;
|
|
231
|
+
if (target?.closest("[data-react-fancy-portal]")) return;
|
|
232
|
+
if (target?.closest('[aria-expanded="true"]')) return;
|
|
233
|
+
e.preventDefault();
|
|
234
|
+
e.stopPropagation();
|
|
235
|
+
setFullscreen(false, { source: "user" });
|
|
236
|
+
};
|
|
237
|
+
window.addEventListener("keydown", onKey, true);
|
|
238
|
+
return () => window.removeEventListener("keydown", onKey, true);
|
|
239
|
+
}, [mode, setFullscreen]);
|
|
240
|
+
return {
|
|
241
|
+
fullscreen,
|
|
242
|
+
mode: fullscreen ? mode : null,
|
|
243
|
+
nativeSupported,
|
|
244
|
+
setFullscreen,
|
|
245
|
+
toggle,
|
|
246
|
+
portalContainer: fullscreen && mode ? ref.current : null,
|
|
247
|
+
labels
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
var CORNERS = {
|
|
251
|
+
"top-left": { top: 12, left: 12 },
|
|
252
|
+
"top-right": { top: 12, right: 12 },
|
|
253
|
+
"bottom-left": { bottom: 12, left: 12 },
|
|
254
|
+
"bottom-right": { bottom: 12, right: 12 }
|
|
255
|
+
};
|
|
256
|
+
var BUTTON_CSS = "[data-fancy-3d-fullscreen-button]:hover { background: var(--fancy-3d-control-bg-hover, rgb(39 39 42 / 0.9)); } [data-fancy-3d-fullscreen-button]:focus-visible { outline: 2px solid var(--fancy-focus, var(--color-blue-500, #3b82f6)); outline-offset: 2px; }";
|
|
257
|
+
function Icon({ exit }) {
|
|
258
|
+
const d = exit ? "M8 3v5H3M21 8h-5V3M16 21v-5h5M3 16h5v5" : "M3 8V3h5M16 3h5v5M21 16v5h-5M8 21H3v-5";
|
|
259
|
+
return /* @__PURE__ */ jsx("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsx("path", { d }) });
|
|
260
|
+
}
|
|
261
|
+
function FullscreenButton({ controller, placement = "bottom-right", style, className, onClick, onMouseDown, ...rest }) {
|
|
262
|
+
const fromContext = useFullscreenContext();
|
|
263
|
+
const fs = controller === void 0 ? fromContext : controller;
|
|
264
|
+
if (!fs) return null;
|
|
265
|
+
const label = fs.fullscreen ? fs.labels.exit : fs.labels.enter;
|
|
266
|
+
const position = placement === "inline" ? {} : { position: "absolute", zIndex: 1, ...CORNERS[placement] };
|
|
267
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
268
|
+
/* @__PURE__ */ jsx("style", { "data-fancy-3d-fullscreen-css": "", children: BUTTON_CSS }),
|
|
269
|
+
/* @__PURE__ */ jsx(
|
|
270
|
+
"button",
|
|
271
|
+
{
|
|
272
|
+
...rest,
|
|
273
|
+
type: "button",
|
|
274
|
+
className,
|
|
275
|
+
"aria-label": label,
|
|
276
|
+
"aria-pressed": fs.fullscreen,
|
|
277
|
+
title: label,
|
|
278
|
+
"data-fancy-3d-fullscreen-button": "",
|
|
279
|
+
"data-fullscreen": fs.fullscreen ? "true" : "false",
|
|
280
|
+
style: {
|
|
281
|
+
display: "inline-flex",
|
|
282
|
+
alignItems: "center",
|
|
283
|
+
justifyContent: "center",
|
|
284
|
+
width: 32,
|
|
285
|
+
height: 32,
|
|
286
|
+
padding: 0,
|
|
287
|
+
border: "1px solid var(--fancy-3d-control-border, rgb(255 255 255 / 0.16))",
|
|
288
|
+
borderRadius: 6,
|
|
289
|
+
background: "var(--fancy-3d-control-bg, rgb(24 24 27 / 0.72))",
|
|
290
|
+
color: "var(--fancy-3d-control-fg, #fafafa)",
|
|
291
|
+
cursor: "pointer",
|
|
292
|
+
pointerEvents: "auto",
|
|
293
|
+
...position,
|
|
294
|
+
...style
|
|
295
|
+
},
|
|
296
|
+
onMouseDown: (e) => {
|
|
297
|
+
onMouseDown?.(e);
|
|
298
|
+
e.preventDefault();
|
|
299
|
+
},
|
|
300
|
+
onClick: (e) => {
|
|
301
|
+
onClick?.(e);
|
|
302
|
+
if (!e.defaultPrevented) fs.toggle({ source: "user" });
|
|
303
|
+
},
|
|
304
|
+
children: /* @__PURE__ */ jsx(Icon, { exit: fs.fullscreen })
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
] });
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export { DEFAULT_FULLSCREEN_LABELS, FullscreenButton, FullscreenContext, nativeFullscreenSupported, useFullscreen, useFullscreenContext };
|
|
311
|
+
//# sourceMappingURL=chunk-UOFTGHV6.js.map
|
|
312
|
+
//# sourceMappingURL=chunk-UOFTGHV6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fullscreen.tsx"],"names":[],"mappings":";;;;AAuDO,IAAM,yBAAA,GAA8C,EAAE,KAAA,EAAO,mBAAA,EAAqB,MAAM,kBAAA;AA6CxF,IAAM,iBAAA,GAAoB,cAA2C,IAAI;AAGzE,SAAS,oBAAA,GAAoD;AAClE,EAAA,OAAO,WAAW,iBAAiB,CAAA;AACrC;AASA,SAAS,iBAAA,GAAoC;AAC3C,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,EAAa,OAAO,IAAA;AAC5C,EAAA,MAAM,CAAA,GAAI,QAAA;AACV,EAAA,OAAO,CAAA,CAAE,iBAAA,IAAqB,CAAA,CAAE,uBAAA,I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UACZ,KAAA,EAAO,qCAAA;AAAA,UACP,MAAA,EAAQ,SAAA;AAAA,UACR,aAAA,EAAe,MAAA;AAAA,UACf,GAAG,QAAA;AAAA,UACH,GAAG;AAAA,SACL;AAAA,QACA,WAAA,EAAa,CAAC,CAAA,KAA0C;AACtD,UAAA,WAAA,GAAc,CAAC,CAAA;AAEf,UAAA,CAAA,CAAE,cAAA,EAAe;AAAA,QACnB,CAAA;AAAA,QACA,OAAA,EAAS,CAAC,CAAA,KAAM;AACd,UAAA,OAAA,GAAU,CAAC,CAAA;AACX,UAAA,IAAI,CAAC,EAAE,gBAAA,EAAkB,EAAA,CAAG,OAAO,EAAE,MAAA,EAAQ,QAAQ,CAAA;AAAA,QACvD,CAAA;AAAA,QAEA,QAAA,kBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAM,EAAA,CAAG,UAAA,EAAY;AAAA;AAAA;AAC7B,GAAA,EACF,CAAA;AAEJ","file":"chunk-UOFTGHV6.js","sourcesContent":["/**\n * `@particle-academy/fancy-3d/fullscreen` — full screen for every fancy-3d\n * viewer, in one place.\n *\n * It full-screens the viewer's ROOT container, never the bare canvas, so\n * everything the viewer renders inside it comes along: the controls overlay,\n * labels, breadcrumbs, fact cards, Monitors. The DOM `<Canvas>`, the\n * fancy-3d-three and fancy-3d-babylon `<Stage>` / `<SceneView>`, and\n * fancy-graph's views all use this hook, so they behave alike.\n *\n * - The browser Fullscreen API where it is available (and Safari's prefixed\n * one); where it is missing or refuses (iPhone Safari, an iframe without\n * `allow=\"fullscreen\"`, an agent asking without a user gesture), an\n * \"expanded\" mode: the root becomes a fixed, full-viewport box.\n * - Esc and the button both exit. In native mode the browser handles Esc; in\n * expanded mode this hook does, unless the key is meant for an open popup.\n * - Keyboard focus stays where it was (the button does not take it), and moves\n * into the viewer if it was outside.\n * - The root changes size, so a renderer that observes its container resizes\n * and re-aims its camera; a `resize` event is also sent for renderers that\n * only listen to the window.\n *\n * This module depends on React alone: no react-fancy, no engine.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type CSSProperties,\n type MouseEvent as ReactMouseEvent,\n type RefObject,\n} from \"react\";\n\n/** How a viewer is full screen: the browser's Fullscreen API, or the fixed full-viewport fallback. */\nexport type FullscreenMode = \"native\" | \"expanded\";\n\n/** Who asked: a click or key (`\"user\"`), code or an agent (`\"api\"`), or the browser's own exit (`\"browser\"`). */\nexport type FullscreenSource = \"user\" | \"api\" | \"browser\";\n\nexport interface FullscreenChangeMeta {\n source: FullscreenSource;\n}\n\nexport interface FullscreenLabels {\n /** Accessible name of the button while not full screen. Default `\"Enter full screen\"`. */\n enter: string;\n /** Accessible name of the button while full screen. Default `\"Exit full screen\"`. */\n exit: string;\n}\n\nexport const DEFAULT_FULLSCREEN_LABELS: FullscreenLabels = { enter: \"Enter full screen\", exit: \"Exit full screen\" };\n\nexport interface UseFullscreenOptions {\n /** Controlled flag. Pair with `onFullscreenChange`. */\n fullscreen?: boolean;\n /** Initial flag when uncontrolled. Default false. */\n defaultFullscreen?: boolean;\n /**\n * Every requested change, with who asked: the button, Esc, a handle call, or\n * the user leaving the browser's own full screen (`source: \"browser\"`, which a\n * controlled host should follow).\n */\n onFullscreenChange?: (fullscreen: boolean, meta: FullscreenChangeMeta) => void;\n /** `\"auto\"` (default): the Fullscreen API where the browser allows it, else expanded. `\"expanded\"`: never the API. */\n mode?: \"auto\" | \"expanded\";\n /** Esc leaves expanded mode. Default true. (In native mode Esc is the browser's and always exits.) */\n closeOnEscape?: boolean;\n /** Stacking order in expanded mode. Default 50, as react-fancy's Modal: its popups (also 50) open above. */\n zIndex?: number;\n labels?: Partial<FullscreenLabels>;\n /**\n * False makes the hook inert: no attribute, no listener, no full screen. For\n * a viewer nested in another that owns full screen (a Stage inside\n * fancy-graph's GraphView3D), which then uses the outer controller. Default true.\n */\n enabled?: boolean;\n}\n\nexport interface FullscreenController {\n /** The requested state. */\n fullscreen: boolean;\n /** The mechanism in effect, or null when not full screen (or while the browser is still deciding). */\n mode: FullscreenMode | null;\n /** Whether this browser offers the Fullscreen API here. False on the server and before mount. */\n nativeSupported: boolean;\n /** The handle method. Source `\"api\"` unless given. */\n setFullscreen(on: boolean, meta?: Partial<FullscreenChangeMeta>): void;\n /** What the button calls. Source `\"user\"` unless given. */\n toggle(meta?: Partial<FullscreenChangeMeta>): void;\n /** The root while full screen, else null: portal popups into it so they stay visible. */\n portalContainer: HTMLElement | null;\n labels: FullscreenLabels;\n}\n\n/** The nearest viewer's full-screen controller. A Stage or view provides one; overlays read it. */\nexport const FullscreenContext = createContext<FullscreenController | null>(null);\n\n/** The nearest viewer's controller, or null outside one. */\nexport function useFullscreenContext(): FullscreenController | null {\n return useContext(FullscreenContext);\n}\n\ntype FsDocument = Document & {\n webkitFullscreenElement?: Element | null;\n webkitFullscreenEnabled?: boolean;\n webkitExitFullscreen?: () => void;\n};\ntype FsElement = HTMLElement & { webkitRequestFullscreen?: () => void };\n\nfunction fullscreenElement(): Element | null {\n if (typeof document === \"undefined\") return null;\n const d = document as FsDocument;\n return d.fullscreenElement ?? d.webkitFullscreenElement ?? null;\n}\n\n/** Whether `el` can go full screen through the browser API. */\nexport function nativeFullscreenSupported(el?: HTMLElement | null): boolean {\n if (typeof document === \"undefined\") return false;\n const d = document as FsDocument;\n const enabled = d.fullscreenEnabled ?? d.webkitFullscreenEnabled;\n if (enabled === false || enabled === undefined) return false;\n const target = (el ?? document.documentElement) as FsElement;\n return typeof target.requestFullscreen === \"function\" || typeof target.webkitRequestFullscreen === \"function\";\n}\n\nfunction requestNative(el: HTMLElement): Promise<void> {\n const e = el as FsElement;\n try {\n if (typeof e.requestFullscreen === \"function\") return Promise.resolve(e.requestFullscreen());\n if (typeof e.webkitRequestFullscreen === \"function\") {\n e.webkitRequestFullscreen();\n return Promise.resolve();\n }\n } catch (err) {\n return Promise.reject(err);\n }\n return Promise.reject(new Error(\"no Fullscreen API\"));\n}\n\nfunction exitNative() {\n const d = document as FsDocument;\n try {\n if (typeof d.exitFullscreen === \"function\") Promise.resolve(d.exitFullscreen()).catch(() => {});\n else d.webkitExitFullscreen?.();\n } catch {\n /* already out */\n }\n}\n\nconst EXPANDED: Array<[keyof CSSStyleDeclaration & string, string]> = [\n [\"position\", \"fixed\"],\n [\"top\", \"0px\"],\n [\"right\", \"0px\"],\n [\"bottom\", \"0px\"],\n [\"left\", \"0px\"],\n [\"width\", \"100%\"],\n [\"height\", \"100%\"],\n [\"maxWidth\", \"none\"],\n [\"maxHeight\", \"none\"],\n [\"margin\", \"0px\"],\n [\"borderRadius\", \"0px\"],\n [\"boxSizing\", \"border-box\"],\n];\n\nfunction isTransparent(color: string): boolean {\n if (!color || color === \"transparent\") return true;\n const m = /rgba?\\(([^)]+)\\)/.exec(color);\n if (!m) return false;\n const parts = m[1].split(/[\\s,/]+/).filter(Boolean);\n return parts.length === 4 && Number.parseFloat(parts[3]) === 0;\n}\n\n/** The first opaque background above `el` (the page's surface), else white. */\nfunction surfaceBehind(el: HTMLElement): string {\n for (let p = el.parentElement; p; p = p.parentElement) {\n const c = getComputedStyle(p).backgroundColor;\n if (!isTransparent(c)) return c;\n }\n return \"rgb(255, 255, 255)\";\n}\n\nconst FOCUS_TARGET =\"canvas[tabindex], [tabindex='0'], button:not([disabled])\";\n\n/**\n * Full screen for the element `ref` points at: the viewer's root container.\n * Controlled with `fullscreen` + `onFullscreenChange`, or uncontrolled. The\n * root gets `data-fancy-3d-fullscreen=\"true|false\"` and, while active,\n * `data-fancy-3d-fullscreen-mode=\"native|expanded\"`.\n */\nexport function useFullscreen<T extends HTMLElement>(ref: RefObject<T | null>, options: UseFullscreenOptions = {}): FullscreenController {\n const { fullscreen: controlled, defaultFullscreen = false, onFullscreenChange, mode: modeOption = \"auto\", closeOnEscape = true, zIndex = 50, enabled = true } = options;\n const labels: FullscreenLabels = { ...DEFAULT_FULLSCREEN_LABELS, ...(options.labels ?? {}) };\n const [inner, setInner] = useState(defaultFullscreen);\n const fullscreen = controlled ?? inner;\n const [mode, setMode] = useState<FullscreenMode | null>(null);\n const [nativeSupported, setNativeSupported] = useState(false);\n\n // What the DOM is actually in. \"pending\": the browser has been asked.\n const actual = useRef<FullscreenMode | \"pending\" | null>(null);\n const requested = useRef(fullscreen);\n requested.current = fullscreen;\n const latest = useRef({ controlled, onFullscreenChange, modeOption, closeOnEscape, zIndex });\n latest.current = { controlled, onFullscreenChange, modeOption, closeOnEscape, zIndex };\n const saved = useRef<{ style: Array<[string, string]>; pageOverflow: string } | null>(null);\n const focusMemo = useRef<HTMLElement | null>(null);\n\n const setFullscreen = useCallback((on: boolean, meta?: Partial<FullscreenChangeMeta>) => {\n if (requested.current === on) return;\n const source = meta?.source ?? \"api\";\n requested.current = on;\n if (latest.current.controlled === undefined) setInner(on);\n latest.current.onFullscreenChange?.(on, { source });\n }, []);\n const toggle = useCallback((meta?: Partial<FullscreenChangeMeta>) => setFullscreen(!requested.current, { source: meta?.source ?? \"user\" }), [setFullscreen]);\n\n // Remember what had focus inside the viewer, and put it back after a switch:\n // a canvas the camera controls listen on keeps its keys.\n const rememberFocus = (el: HTMLElement) => {\n const active = document.activeElement;\n focusMemo.current = active instanceof HTMLElement && el.contains(active) ? active : null;\n };\n const restoreFocus = (el: HTMLElement, entering: boolean) => {\n const memo = focusMemo.current;\n if (memo?.isConnected) {\n if (document.activeElement !== memo) memo.focus({ preventScroll: true });\n } else if (entering && !el.contains(document.activeElement)) {\n el.querySelector<HTMLElement>(FOCUS_TARGET)?.focus({ preventScroll: true });\n }\n };\n\n const notifyResize = () => {\n if (typeof window === \"undefined\") return;\n const fire = () => window.dispatchEvent(new Event(\"resize\"));\n if (typeof requestAnimationFrame === \"function\") requestAnimationFrame(fire);\n else fire();\n };\n\n const expand = (el: HTMLElement) => {\n if (!saved.current) {\n saved.current = {\n style: [...EXPANDED.map(([k]) => k), \"zIndex\"].map((k) => [k, (el.style as unknown as Record<string, string>)[k]]),\n pageOverflow: document.documentElement.style.overflow,\n };\n }\n const s = el.style as unknown as Record<string, string>;\n for (const [k, v] of EXPANDED) s[k] = v;\n s.zIndex = String(latest.current.zIndex);\n document.documentElement.style.overflow = \"hidden\";\n actual.current = \"expanded\";\n el.setAttribute(\"data-fancy-3d-fullscreen-mode\", \"expanded\");\n setMode(\"expanded\");\n restoreFocus(el, true);\n notifyResize();\n };\n\n const collapse = (el: HTMLElement) => {\n const memo = saved.current;\n if (memo) {\n const s = el.style as unknown as Record<string, string>;\n for (const [k, v] of memo.style) s[k] = v;\n document.documentElement.style.overflow = memo.pageOverflow;\n saved.current = null;\n }\n };\n\n // A transparent root would show the browser's black backdrop (native) or the\n // page through it (expanded): give it the page's own surface while full screen.\n const backdrop = useRef<string | null>(null);\n const applyBackdrop = (el: HTMLElement) => {\n if (backdrop.current !== null || !isTransparent(getComputedStyle(el).backgroundColor)) return;\n backdrop.current = el.style.backgroundColor;\n el.style.backgroundColor = surfaceBehind(el);\n };\n const restoreBackdrop = (el: HTMLElement) => {\n if (backdrop.current === null) return;\n el.style.backgroundColor = backdrop.current;\n backdrop.current = null;\n };\n\n const enterDom = (el: HTMLElement) => {\n if (actual.current !== null) return;\n rememberFocus(el);\n el.setAttribute(\"data-fancy-3d-fullscreen\", \"true\");\n applyBackdrop(el);\n if (latest.current.modeOption === \"auto\" && nativeFullscreenSupported(el)) {\n actual.current = \"pending\";\n requestNative(el).then(\n () => {\n // Some engines resolve without firing the event; settle here too.\n if (actual.current === \"pending\" && fullscreenElement() === el) settleNative(el);\n },\n () => {\n if (actual.current === \"pending\" && requested.current) expand(el);\n },\n );\n } else {\n expand(el);\n }\n };\n\n const settleNative = (el: HTMLElement) => {\n actual.current = \"native\";\n el.setAttribute(\"data-fancy-3d-fullscreen-mode\", \"native\");\n setMode(\"native\");\n restoreFocus(el, true);\n };\n\n const leaveDom = (el: HTMLElement) => {\n const was = actual.current;\n if (was === null) return;\n rememberFocus(el);\n actual.current = null;\n if (was === \"native\" || was === \"pending\") {\n if (fullscreenElement() === el) exitNative();\n }\n collapse(el);\n restoreBackdrop(el);\n el.setAttribute(\"data-fancy-3d-fullscreen\", \"false\");\n el.removeAttribute(\"data-fancy-3d-fullscreen-mode\");\n setMode(null);\n restoreFocus(el, false);\n notifyResize();\n };\n\n // Mount: the handle attribute, whether the API exists, the browser's own exits.\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el || !enabled) return;\n if (!el.hasAttribute(\"data-fancy-3d-fullscreen\")) el.setAttribute(\"data-fancy-3d-fullscreen\", \"false\");\n setNativeSupported(nativeFullscreenSupported(el));\n const onChange = () => {\n const now = fullscreenElement();\n if (now === el) {\n if (actual.current === \"pending\") settleNative(el);\n // Asked to leave while the browser was still entering.\n else if (actual.current === null) exitNative();\n } else if (actual.current === \"native\") {\n // Left through the browser: Esc, F11, the close pill.\n actual.current = null;\n restoreBackdrop(el);\n el.setAttribute(\"data-fancy-3d-fullscreen\", \"false\");\n el.removeAttribute(\"data-fancy-3d-fullscreen-mode\");\n setMode(null);\n setFullscreen(false, { source: \"browser\" });\n restoreFocus(el, false);\n }\n };\n document.addEventListener(\"fullscreenchange\", onChange);\n document.addEventListener(\"webkitfullscreenchange\", onChange);\n return () => {\n document.removeEventListener(\"fullscreenchange\", onChange);\n document.removeEventListener(\"webkitfullscreenchange\", onChange);\n leaveDom(el);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled]);\n\n // Follow the requested state.\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el || !enabled) return;\n if (fullscreen) enterDom(el);\n else leaveDom(el);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fullscreen, enabled]);\n\n // Esc leaves expanded mode. Capture phase at the window, so it is handled\n // once, before a canvas's own Esc (clear the selection) runs: the same as\n // native full screen, where the browser takes Esc.\n useEffect(() => {\n if (mode !== \"expanded\") return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== \"Escape\" || e.isComposing || !latest.current.closeOnEscape) return;\n const target = e.target instanceof Element ? e.target : null;\n // An open popup owns this Esc: a react-fancy portal, or a trigger whose listbox is open.\n if (target?.closest(\"[data-react-fancy-portal]\")) return;\n if (target?.closest('[aria-expanded=\"true\"]')) return;\n e.preventDefault();\n e.stopPropagation();\n setFullscreen(false, { source: \"user\" });\n };\n window.addEventListener(\"keydown\", onKey, true);\n return () => window.removeEventListener(\"keydown\", onKey, true);\n }, [mode, setFullscreen]);\n\n return {\n fullscreen,\n mode: fullscreen ? mode : null,\n nativeSupported,\n setFullscreen,\n toggle,\n portalContainer: fullscreen && mode ? ref.current : null,\n labels,\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* The button */\n/* ------------------------------------------------------------------ */\n\nexport type FullscreenButtonPlacement = \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\" | \"inline\";\n\nexport interface FullscreenButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"children\"> {\n /** The controller to drive. Default: the nearest viewer's (`FullscreenContext`). */\n controller?: FullscreenController | null;\n /** A corner of the viewer, or `\"inline\"` to sit in a toolbar. Default `\"bottom-right\"`. */\n placement?: FullscreenButtonPlacement;\n}\n\nconst CORNERS: Record<Exclude<FullscreenButtonPlacement, \"inline\">, CSSProperties> = {\n \"top-left\": { top: 12, left: 12 },\n \"top-right\": { top: 12, right: 12 },\n \"bottom-left\": { bottom: 12, left: 12 },\n \"bottom-right\": { bottom: 12, right: 12 },\n};\n\n/**\n * Focus ring and hover for the button. A scoped `<style>` rather than utility\n * classes: consumers are not guaranteed to scan this package's dist, and a\n * class nobody generates is a ring nobody sees. Colours are CSS variables a\n * host can set.\n */\nconst BUTTON_CSS =\n \"[data-fancy-3d-fullscreen-button]:hover { background: var(--fancy-3d-control-bg-hover, rgb(39 39 42 / 0.9)); }\" +\n \" [data-fancy-3d-fullscreen-button]:focus-visible { outline: 2px solid var(--fancy-focus, var(--color-blue-500, #3b82f6)); outline-offset: 2px; }\";\n\nfunction Icon({ exit }: { exit: boolean }) {\n // Four corners pointing out (enter) or in (exit).\n const d = exit ? \"M8 3v5H3M21 8h-5V3M16 21v-5h5M3 16h5v5\" : \"M3 8V3h5M16 3h5v5M21 16v5h-5M8 21H3v-5\";\n return (\n <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n <path d={d} />\n </svg>\n );\n}\n\n/**\n * The full-screen toggle. Renders nothing outside a viewer. Carries\n * `data-fancy-3d-fullscreen-button` and `data-fullscreen=\"true|false\"`, and\n * leaves keyboard focus where it was, so the camera keys keep working.\n */\nexport function FullscreenButton({ controller, placement = \"bottom-right\", style, className, onClick, onMouseDown, ...rest }: FullscreenButtonProps) {\n const fromContext = useFullscreenContext();\n const fs = controller === undefined ? fromContext : controller;\n if (!fs) return null;\n const label = fs.fullscreen ? fs.labels.exit : fs.labels.enter;\n const position: CSSProperties = placement === \"inline\" ? {} : { position: \"absolute\", zIndex: 1, ...CORNERS[placement] };\n return (\n <>\n <style data-fancy-3d-fullscreen-css=\"\">{BUTTON_CSS}</style>\n <button\n {...rest}\n type=\"button\"\n className={className}\n aria-label={label}\n aria-pressed={fs.fullscreen}\n title={label}\n data-fancy-3d-fullscreen-button=\"\"\n data-fullscreen={fs.fullscreen ? \"true\" : \"false\"}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: 32,\n height: 32,\n padding: 0,\n border: \"1px solid var(--fancy-3d-control-border, rgb(255 255 255 / 0.16))\",\n borderRadius: 6,\n background: \"var(--fancy-3d-control-bg, rgb(24 24 27 / 0.72))\",\n color: \"var(--fancy-3d-control-fg, #fafafa)\",\n cursor: \"pointer\",\n pointerEvents: \"auto\",\n ...position,\n ...style,\n }}\n onMouseDown={(e: ReactMouseEvent<HTMLButtonElement>) => {\n onMouseDown?.(e);\n // A pointer click must not take focus from the canvas: its keys drive the camera.\n e.preventDefault();\n }}\n onClick={(e) => {\n onClick?.(e);\n if (!e.defaultPrevented) fs.toggle({ source: \"user\" });\n }}\n >\n <Icon exit={fs.fullscreen} />\n </button>\n </>\n );\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPBKOUAUY_cjs = require('./chunk-PBKOUAUY.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "DEFAULT_FULLSCREEN_LABELS", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkPBKOUAUY_cjs.DEFAULT_FULLSCREEN_LABELS; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "FullscreenButton", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkPBKOUAUY_cjs.FullscreenButton; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "FullscreenContext", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkPBKOUAUY_cjs.FullscreenContext; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "nativeFullscreenSupported", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkPBKOUAUY_cjs.nativeFullscreenSupported; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "useFullscreen", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkPBKOUAUY_cjs.useFullscreen; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "useFullscreenContext", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkPBKOUAUY_cjs.useFullscreenContext; }
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=fullscreen.cjs.map
|
|
32
|
+
//# sourceMappingURL=fullscreen.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"fullscreen.cjs"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
/** How a viewer is full screen: the browser's Fullscreen API, or the fixed full-viewport fallback. */
|
|
5
|
+
type FullscreenMode = "native" | "expanded";
|
|
6
|
+
/** Who asked: a click or key (`"user"`), code or an agent (`"api"`), or the browser's own exit (`"browser"`). */
|
|
7
|
+
type FullscreenSource = "user" | "api" | "browser";
|
|
8
|
+
interface FullscreenChangeMeta {
|
|
9
|
+
source: FullscreenSource;
|
|
10
|
+
}
|
|
11
|
+
interface FullscreenLabels {
|
|
12
|
+
/** Accessible name of the button while not full screen. Default `"Enter full screen"`. */
|
|
13
|
+
enter: string;
|
|
14
|
+
/** Accessible name of the button while full screen. Default `"Exit full screen"`. */
|
|
15
|
+
exit: string;
|
|
16
|
+
}
|
|
17
|
+
declare const DEFAULT_FULLSCREEN_LABELS: FullscreenLabels;
|
|
18
|
+
interface UseFullscreenOptions {
|
|
19
|
+
/** Controlled flag. Pair with `onFullscreenChange`. */
|
|
20
|
+
fullscreen?: boolean;
|
|
21
|
+
/** Initial flag when uncontrolled. Default false. */
|
|
22
|
+
defaultFullscreen?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Every requested change, with who asked: the button, Esc, a handle call, or
|
|
25
|
+
* the user leaving the browser's own full screen (`source: "browser"`, which a
|
|
26
|
+
* controlled host should follow).
|
|
27
|
+
*/
|
|
28
|
+
onFullscreenChange?: (fullscreen: boolean, meta: FullscreenChangeMeta) => void;
|
|
29
|
+
/** `"auto"` (default): the Fullscreen API where the browser allows it, else expanded. `"expanded"`: never the API. */
|
|
30
|
+
mode?: "auto" | "expanded";
|
|
31
|
+
/** Esc leaves expanded mode. Default true. (In native mode Esc is the browser's and always exits.) */
|
|
32
|
+
closeOnEscape?: boolean;
|
|
33
|
+
/** Stacking order in expanded mode. Default 50, as react-fancy's Modal: its popups (also 50) open above. */
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
labels?: Partial<FullscreenLabels>;
|
|
36
|
+
/**
|
|
37
|
+
* False makes the hook inert: no attribute, no listener, no full screen. For
|
|
38
|
+
* a viewer nested in another that owns full screen (a Stage inside
|
|
39
|
+
* fancy-graph's GraphView3D), which then uses the outer controller. Default true.
|
|
40
|
+
*/
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface FullscreenController {
|
|
44
|
+
/** The requested state. */
|
|
45
|
+
fullscreen: boolean;
|
|
46
|
+
/** The mechanism in effect, or null when not full screen (or while the browser is still deciding). */
|
|
47
|
+
mode: FullscreenMode | null;
|
|
48
|
+
/** Whether this browser offers the Fullscreen API here. False on the server and before mount. */
|
|
49
|
+
nativeSupported: boolean;
|
|
50
|
+
/** The handle method. Source `"api"` unless given. */
|
|
51
|
+
setFullscreen(on: boolean, meta?: Partial<FullscreenChangeMeta>): void;
|
|
52
|
+
/** What the button calls. Source `"user"` unless given. */
|
|
53
|
+
toggle(meta?: Partial<FullscreenChangeMeta>): void;
|
|
54
|
+
/** The root while full screen, else null: portal popups into it so they stay visible. */
|
|
55
|
+
portalContainer: HTMLElement | null;
|
|
56
|
+
labels: FullscreenLabels;
|
|
57
|
+
}
|
|
58
|
+
/** The nearest viewer's full-screen controller. A Stage or view provides one; overlays read it. */
|
|
59
|
+
declare const FullscreenContext: react.Context<FullscreenController | null>;
|
|
60
|
+
/** The nearest viewer's controller, or null outside one. */
|
|
61
|
+
declare function useFullscreenContext(): FullscreenController | null;
|
|
62
|
+
/** Whether `el` can go full screen through the browser API. */
|
|
63
|
+
declare function nativeFullscreenSupported(el?: HTMLElement | null): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Full screen for the element `ref` points at: the viewer's root container.
|
|
66
|
+
* Controlled with `fullscreen` + `onFullscreenChange`, or uncontrolled. The
|
|
67
|
+
* root gets `data-fancy-3d-fullscreen="true|false"` and, while active,
|
|
68
|
+
* `data-fancy-3d-fullscreen-mode="native|expanded"`.
|
|
69
|
+
*/
|
|
70
|
+
declare function useFullscreen<T extends HTMLElement>(ref: RefObject<T | null>, options?: UseFullscreenOptions): FullscreenController;
|
|
71
|
+
type FullscreenButtonPlacement = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "inline";
|
|
72
|
+
interface FullscreenButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "children"> {
|
|
73
|
+
/** The controller to drive. Default: the nearest viewer's (`FullscreenContext`). */
|
|
74
|
+
controller?: FullscreenController | null;
|
|
75
|
+
/** A corner of the viewer, or `"inline"` to sit in a toolbar. Default `"bottom-right"`. */
|
|
76
|
+
placement?: FullscreenButtonPlacement;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The full-screen toggle. Renders nothing outside a viewer. Carries
|
|
80
|
+
* `data-fancy-3d-fullscreen-button` and `data-fullscreen="true|false"`, and
|
|
81
|
+
* leaves keyboard focus where it was, so the camera keys keep working.
|
|
82
|
+
*/
|
|
83
|
+
declare function FullscreenButton({ controller, placement, style, className, onClick, onMouseDown, ...rest }: FullscreenButtonProps): react.JSX.Element | null;
|
|
84
|
+
|
|
85
|
+
export { DEFAULT_FULLSCREEN_LABELS, FullscreenButton, type FullscreenButtonPlacement, type FullscreenButtonProps, type FullscreenChangeMeta, FullscreenContext, type FullscreenController, type FullscreenLabels, type FullscreenMode, type FullscreenSource, type UseFullscreenOptions, nativeFullscreenSupported, useFullscreen, useFullscreenContext };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
/** How a viewer is full screen: the browser's Fullscreen API, or the fixed full-viewport fallback. */
|
|
5
|
+
type FullscreenMode = "native" | "expanded";
|
|
6
|
+
/** Who asked: a click or key (`"user"`), code or an agent (`"api"`), or the browser's own exit (`"browser"`). */
|
|
7
|
+
type FullscreenSource = "user" | "api" | "browser";
|
|
8
|
+
interface FullscreenChangeMeta {
|
|
9
|
+
source: FullscreenSource;
|
|
10
|
+
}
|
|
11
|
+
interface FullscreenLabels {
|
|
12
|
+
/** Accessible name of the button while not full screen. Default `"Enter full screen"`. */
|
|
13
|
+
enter: string;
|
|
14
|
+
/** Accessible name of the button while full screen. Default `"Exit full screen"`. */
|
|
15
|
+
exit: string;
|
|
16
|
+
}
|
|
17
|
+
declare const DEFAULT_FULLSCREEN_LABELS: FullscreenLabels;
|
|
18
|
+
interface UseFullscreenOptions {
|
|
19
|
+
/** Controlled flag. Pair with `onFullscreenChange`. */
|
|
20
|
+
fullscreen?: boolean;
|
|
21
|
+
/** Initial flag when uncontrolled. Default false. */
|
|
22
|
+
defaultFullscreen?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Every requested change, with who asked: the button, Esc, a handle call, or
|
|
25
|
+
* the user leaving the browser's own full screen (`source: "browser"`, which a
|
|
26
|
+
* controlled host should follow).
|
|
27
|
+
*/
|
|
28
|
+
onFullscreenChange?: (fullscreen: boolean, meta: FullscreenChangeMeta) => void;
|
|
29
|
+
/** `"auto"` (default): the Fullscreen API where the browser allows it, else expanded. `"expanded"`: never the API. */
|
|
30
|
+
mode?: "auto" | "expanded";
|
|
31
|
+
/** Esc leaves expanded mode. Default true. (In native mode Esc is the browser's and always exits.) */
|
|
32
|
+
closeOnEscape?: boolean;
|
|
33
|
+
/** Stacking order in expanded mode. Default 50, as react-fancy's Modal: its popups (also 50) open above. */
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
labels?: Partial<FullscreenLabels>;
|
|
36
|
+
/**
|
|
37
|
+
* False makes the hook inert: no attribute, no listener, no full screen. For
|
|
38
|
+
* a viewer nested in another that owns full screen (a Stage inside
|
|
39
|
+
* fancy-graph's GraphView3D), which then uses the outer controller. Default true.
|
|
40
|
+
*/
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface FullscreenController {
|
|
44
|
+
/** The requested state. */
|
|
45
|
+
fullscreen: boolean;
|
|
46
|
+
/** The mechanism in effect, or null when not full screen (or while the browser is still deciding). */
|
|
47
|
+
mode: FullscreenMode | null;
|
|
48
|
+
/** Whether this browser offers the Fullscreen API here. False on the server and before mount. */
|
|
49
|
+
nativeSupported: boolean;
|
|
50
|
+
/** The handle method. Source `"api"` unless given. */
|
|
51
|
+
setFullscreen(on: boolean, meta?: Partial<FullscreenChangeMeta>): void;
|
|
52
|
+
/** What the button calls. Source `"user"` unless given. */
|
|
53
|
+
toggle(meta?: Partial<FullscreenChangeMeta>): void;
|
|
54
|
+
/** The root while full screen, else null: portal popups into it so they stay visible. */
|
|
55
|
+
portalContainer: HTMLElement | null;
|
|
56
|
+
labels: FullscreenLabels;
|
|
57
|
+
}
|
|
58
|
+
/** The nearest viewer's full-screen controller. A Stage or view provides one; overlays read it. */
|
|
59
|
+
declare const FullscreenContext: react.Context<FullscreenController | null>;
|
|
60
|
+
/** The nearest viewer's controller, or null outside one. */
|
|
61
|
+
declare function useFullscreenContext(): FullscreenController | null;
|
|
62
|
+
/** Whether `el` can go full screen through the browser API. */
|
|
63
|
+
declare function nativeFullscreenSupported(el?: HTMLElement | null): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Full screen for the element `ref` points at: the viewer's root container.
|
|
66
|
+
* Controlled with `fullscreen` + `onFullscreenChange`, or uncontrolled. The
|
|
67
|
+
* root gets `data-fancy-3d-fullscreen="true|false"` and, while active,
|
|
68
|
+
* `data-fancy-3d-fullscreen-mode="native|expanded"`.
|
|
69
|
+
*/
|
|
70
|
+
declare function useFullscreen<T extends HTMLElement>(ref: RefObject<T | null>, options?: UseFullscreenOptions): FullscreenController;
|
|
71
|
+
type FullscreenButtonPlacement = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "inline";
|
|
72
|
+
interface FullscreenButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "children"> {
|
|
73
|
+
/** The controller to drive. Default: the nearest viewer's (`FullscreenContext`). */
|
|
74
|
+
controller?: FullscreenController | null;
|
|
75
|
+
/** A corner of the viewer, or `"inline"` to sit in a toolbar. Default `"bottom-right"`. */
|
|
76
|
+
placement?: FullscreenButtonPlacement;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The full-screen toggle. Renders nothing outside a viewer. Carries
|
|
80
|
+
* `data-fancy-3d-fullscreen-button` and `data-fullscreen="true|false"`, and
|
|
81
|
+
* leaves keyboard focus where it was, so the camera keys keep working.
|
|
82
|
+
*/
|
|
83
|
+
declare function FullscreenButton({ controller, placement, style, className, onClick, onMouseDown, ...rest }: FullscreenButtonProps): react.JSX.Element | null;
|
|
84
|
+
|
|
85
|
+
export { DEFAULT_FULLSCREEN_LABELS, FullscreenButton, type FullscreenButtonPlacement, type FullscreenButtonProps, type FullscreenChangeMeta, FullscreenContext, type FullscreenController, type FullscreenLabels, type FullscreenMode, type FullscreenSource, type UseFullscreenOptions, nativeFullscreenSupported, useFullscreen, useFullscreenContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"fullscreen.js"}
|