@particle-academy/fancy-3d 0.6.0 → 0.7.1
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 +56 -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-3SBP46Z7.js +317 -0
- package/dist/chunk-3SBP46Z7.js.map +1 -0
- package/dist/chunk-7D3SIGGX.cjs +324 -0
- package/dist/chunk-7D3SIGGX.cjs.map +1 -0
- package/dist/chunk-JY26QMCY.cjs +694 -0
- package/dist/chunk-JY26QMCY.cjs.map +1 -0
- package/dist/{chunk-F3HZDJSN.js → chunk-XBPQK2TY.js} +23 -143
- package/dist/chunk-XBPQK2TY.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 +99 -0
- package/package.json +14 -1
- package/dist/chunk-F3HZDJSN.js.map +0 -1
|
@@ -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"}
|