@deltarobotics/uhd-viewer 0.0.0-stage → 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/CHANGELOG.md +41 -0
- package/LICENSE +202 -0
- package/NOTICE +22 -0
- package/README.md +168 -2
- package/bin/serve.d.mts +62 -0
- package/bin/serve.mjs +257 -0
- package/bin/uhd-viewer.mjs +75 -0
- package/dist/app/assets/KodeMono-Bold-DdIivhPN.woff2 +0 -0
- package/dist/app/assets/KodeMono-Medium-CVnTuv5A.ttf +0 -0
- package/dist/app/assets/KodeMono-Regular-Bdr_-rJX.woff2 +0 -0
- package/dist/app/assets/KodeMono-SemiBold-JAfn5Dpm.ttf +0 -0
- package/dist/app/assets/index-Boi2erhd.css +2 -0
- package/dist/app/assets/index-CkpIRYgM.js +3853 -0
- package/dist/app/index.html +16 -0
- package/dist/components/components.css +6108 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +26048 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/types/uhd-viewer/src/api.d.ts +286 -0
- package/dist/components/types/uhd-viewer/src/cad/CadView.d.ts +52 -0
- package/dist/components/types/uhd-viewer/src/cad/ModelView.d.ts +28 -0
- package/dist/components/types/uhd-viewer/src/cad/explode.d.ts +110 -0
- package/dist/components/types/uhd-viewer/src/cad/explodeSample.d.ts +25 -0
- package/dist/components/types/uhd-viewer/src/cad/findings.d.ts +41 -0
- package/dist/components/types/uhd-viewer/src/cad/labels.d.ts +76 -0
- package/dist/components/types/uhd-viewer/src/cad/model.d.ts +132 -0
- package/dist/components/types/uhd-viewer/src/cad/row.d.ts +15 -0
- package/dist/components/types/uhd-viewer/src/cad/scene.d.ts +95 -0
- package/dist/components/types/uhd-viewer/src/cad/scope.d.ts +89 -0
- package/dist/components/types/uhd-viewer/src/canvas/Canvas.d.ts +86 -0
- package/dist/components/types/uhd-viewer/src/canvas/Icon.d.ts +5 -0
- package/dist/components/types/uhd-viewer/src/canvas/LinkEdge.d.ts +40 -0
- package/dist/components/types/uhd-viewer/src/canvas/Port.d.ts +18 -0
- package/dist/components/types/uhd-viewer/src/canvas/actions.d.ts +5 -0
- package/dist/components/types/uhd-viewer/src/canvas/geometry.d.ts +72 -0
- package/dist/components/types/uhd-viewer/src/canvas/interaction.d.ts +162 -0
- package/dist/components/types/uhd-viewer/src/canvas/nodes.d.ts +43 -0
- package/dist/components/types/uhd-viewer/src/canvas/reveal.d.ts +37 -0
- package/dist/components/types/uhd-viewer/src/canvas/rightDrag.d.ts +51 -0
- package/dist/components/types/uhd-viewer/src/canvas/routing.d.ts +28 -0
- package/dist/components/types/uhd-viewer/src/chrome/ArtifactCards.d.ts +30 -0
- package/dist/components/types/uhd-viewer/src/chrome/Artifacts.d.ts +44 -0
- package/dist/components/types/uhd-viewer/src/chrome/BoardInspector.d.ts +53 -0
- package/dist/components/types/uhd-viewer/src/chrome/Chrome.d.ts +116 -0
- package/dist/components/types/uhd-viewer/src/chrome/Evidence.d.ts +20 -0
- package/dist/components/types/uhd-viewer/src/chrome/InterfaceCards.d.ts +56 -0
- package/dist/components/types/uhd-viewer/src/chrome/PairView.d.ts +37 -0
- package/dist/components/types/uhd-viewer/src/chrome/Sections.d.ts +107 -0
- package/dist/components/types/uhd-viewer/src/components.d.ts +60 -0
- package/dist/components/types/uhd-viewer/src/host/channel.d.ts +49 -0
- package/dist/components/types/uhd-viewer/src/host/context.d.ts +29 -0
- package/dist/components/types/uhd-viewer/src/host/protocol.d.ts +22 -0
- package/dist/components/types/uhd-viewer/src/host/targets.d.ts +85 -0
- package/dist/components/types/uhd-viewer/src/layout/board-layout.d.ts +69 -0
- package/dist/components/types/uhd-viewer/src/layout/card-body.d.ts +64 -0
- package/dist/components/types/uhd-viewer/src/layout/layout.d.ts +94 -0
- package/dist/components/types/uhd-viewer/src/layout/module-layout.d.ts +32 -0
- package/dist/components/types/uhd-viewer/src/layout/router.d.ts +55 -0
- package/dist/components/types/uhd-viewer/src/layout/taps.d.ts +20 -0
- package/dist/components/types/uhd-viewer/src/model/artifacts.d.ts +129 -0
- package/dist/components/types/uhd-viewer/src/model/classification.d.ts +38 -0
- package/dist/components/types/uhd-viewer/src/model/diagnostics.d.ts +27 -0
- package/dist/components/types/uhd-viewer/src/model/evidence.d.ts +63 -0
- package/dist/components/types/uhd-viewer/src/model/from-uhd.d.ts +57 -0
- package/dist/components/types/uhd-viewer/src/model/hierarchy.d.ts +169 -0
- package/dist/components/types/uhd-viewer/src/model/isolate.d.ts +33 -0
- package/dist/components/types/uhd-viewer/src/model/nets.d.ts +53 -0
- package/dist/components/types/uhd-viewer/src/model/outputs.d.ts +79 -0
- package/dist/components/types/uhd-viewer/src/model/slots.d.ts +182 -0
- package/dist/components/types/uhd-viewer/src/model/types.d.ts +213 -0
- package/dist/components/types/uhd-viewer/src/options.d.ts +27 -0
- package/dist/components/types/uhd-viewer/src/source/source.d.ts +109 -0
- package/dist/components/types/uhd-viewer/src/source/tolerant.d.ts +45 -0
- package/dist/components/types/uhd-viewer/src/theme/ThemeProvider.d.ts +33 -0
- package/dist/components/types/uhd-viewer/src/theme/adapters.d.ts +28 -0
- package/dist/components/types/uhd-viewer/src/theme/resolve.d.ts +19 -0
- package/dist/components/types/uhd-viewer/src/theme/themes.d.ts +67 -0
- package/dist/components/types/uhd-viewer/src/theme/tokens.d.ts +175 -0
- package/dist/components/types/uhd-viewer/src/ui/Inspector.d.ts +45 -0
- package/dist/components/types/uhd-viewer/src/ui/Legend.d.ts +40 -0
- package/dist/components/types/uhd-viewer/src/ui/ScrollArea.d.ts +16 -0
- package/dist/components/types/uhd-viewer/src/ui/Toolbar.d.ts +49 -0
- package/dist/components/types/uhd-viewer/src/ui/Tooltips.d.ts +3 -0
- package/dist/components/types/uhd-viewer/src/ui/cx.d.ts +2 -0
- package/dist/components/types/uhd-viewer/src/ui/legendFit.d.ts +42 -0
- package/dist/components/types/uhd-viewer/src/viewer/controller.d.ts +218 -0
- package/dist/components/types/uhd-viewer/src/viewer/details.d.ts +81 -0
- package/dist/components/types/uhd-viewer/src/viewer/hierarchy.d.ts +60 -0
- package/dist/components/types/uhd-viewer/src/viewer/mount.d.ts +12 -0
- package/dist/components/types/uhd-viewer/src/viewer/views.d.ts +156 -0
- package/dist/headless/index.d.ts +71 -0
- package/dist/headless/index.js +7425 -0
- package/dist/headless/index.js.map +1 -0
- package/dist/lib/api.d.ts +252 -0
- package/dist/lib/uhd-viewer.css +3 -0
- package/dist/lib/uhd-viewer.d.ts +4 -0
- package/dist/lib/uhd-viewer.js +97469 -0
- package/package.json +110 -4
- package/src/styles/fonts/OFL.txt +93 -0
- package/src/styles/tailwind-theme.css +48 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts a theme on the viewer's root element and tells the components that
|
|
3
|
+
* draw outside CSS (the 3D scene) when it changes. Everything rendered inside
|
|
4
|
+
* reads the tokens as CSS variables; popovers portal into the same root so
|
|
5
|
+
* they keep them.
|
|
6
|
+
*/
|
|
7
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
8
|
+
import { type Theme, type ThemeToken } from "./tokens";
|
|
9
|
+
import { type ThemeAdapter } from "./adapters";
|
|
10
|
+
export interface ThemeState {
|
|
11
|
+
theme: Theme;
|
|
12
|
+
/** The themed element: tooltips and menus portal here so they keep the tokens. */
|
|
13
|
+
root: HTMLElement | null;
|
|
14
|
+
}
|
|
15
|
+
/** The current theme and the themed root element. */
|
|
16
|
+
export declare const useTheme: () => ThemeState;
|
|
17
|
+
export interface ThemeProviderProps {
|
|
18
|
+
/** Where the theme comes from (default: the viewer's own, following the system). */
|
|
19
|
+
adapter?: ThemeAdapter;
|
|
20
|
+
/** Or one theme (wins over `adapter`). */
|
|
21
|
+
theme?: Theme;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/** The themed root: a full-size element carrying the tokens. */
|
|
27
|
+
export declare function ThemeProvider({ adapter, theme: fixed, className, style, children }: ThemeProviderProps): import("react").JSX.Element;
|
|
28
|
+
/**
|
|
29
|
+
* A token's colour as `#rrggbb` (alpha dropped), resolved on `element`:
|
|
30
|
+
* for canvases that cannot read CSS variables or modern colour syntax
|
|
31
|
+
* (`oklch()`, `color-mix()`), like the 3D scene's background and grid.
|
|
32
|
+
*/
|
|
33
|
+
export declare function tokenColor(element: Element | null, name: ThemeToken, fallback?: string): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Theme, type ThemeScheme } from "./tokens";
|
|
2
|
+
export interface ThemeAdapter {
|
|
3
|
+
id: string;
|
|
4
|
+
/** The theme to show now. */
|
|
5
|
+
current(): Theme;
|
|
6
|
+
/** Calls `onChange` whenever the theme changes; returns the unsubscribe. Absent: the theme never changes. */
|
|
7
|
+
subscribe?(onChange: (theme: Theme) => void): () => void;
|
|
8
|
+
}
|
|
9
|
+
/** One fixed theme. */
|
|
10
|
+
export declare const staticTheme: (theme: Theme) => ThemeAdapter;
|
|
11
|
+
/** Several adapters' worth of themes, picked by id (a host's theme switcher). */
|
|
12
|
+
export declare function pickTheme(themes: readonly Theme[], id: string | null | undefined, fallback: Theme): Theme;
|
|
13
|
+
/** The viewer's own themes: dark, light, or the system's preference (default). */
|
|
14
|
+
export declare function defaultThemeAdapter(scheme?: "dark" | "light" | "system", win?: Window | undefined): ThemeAdapter;
|
|
15
|
+
/** The scheme of a VS Code webview, from the class VS Code puts on its body. */
|
|
16
|
+
export declare function vscodeScheme(body: {
|
|
17
|
+
classList: {
|
|
18
|
+
contains(c: string): boolean;
|
|
19
|
+
};
|
|
20
|
+
} | undefined): ThemeScheme;
|
|
21
|
+
/** The VS Code tokens for one scheme. */
|
|
22
|
+
export declare function vscodeTheme(scheme: ThemeScheme): Theme;
|
|
23
|
+
/**
|
|
24
|
+
* Follows the VS Code colour theme of the webview the viewer runs in: the
|
|
25
|
+
* tokens refer to VS Code's variables, so a colour change inside a scheme
|
|
26
|
+
* needs nothing; a change of scheme (VS Code swaps its body class) re-themes.
|
|
27
|
+
*/
|
|
28
|
+
export declare function vscodeThemeAdapter(doc?: Document | undefined): ThemeAdapter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** A host's `theme` option (api.ts) as a theme adapter. */
|
|
2
|
+
import type { ViewerThemeOption } from "../api";
|
|
3
|
+
import { type ThemeAdapter } from "./adapters";
|
|
4
|
+
import { type Theme } from "./tokens";
|
|
5
|
+
/** A theme given with some tokens: the rest from the default of its scheme. */
|
|
6
|
+
export declare function completeTheme(theme: {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
scheme: Theme["scheme"];
|
|
10
|
+
tokens: Partial<Record<string, string>>;
|
|
11
|
+
}): Theme;
|
|
12
|
+
/**
|
|
13
|
+
* - absent or `"dark"` / `"light"`: the viewer's own dark (as it has always
|
|
14
|
+
* looked) or light theme; `"system"`: whichever the system prefers;
|
|
15
|
+
* - `"vscode"`: the VS Code adapter (in a VS Code webview);
|
|
16
|
+
* - a theme object: that theme (missing tokens from the default);
|
|
17
|
+
* - an adapter (`{ current, subscribe? }`): the host's own.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveTheme(option: ViewerThemeOption | undefined): ThemeAdapter;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The viewer's own themes: neutral dark and light. They carry no brand; a
|
|
3
|
+
* host's brand theme starts from one of these (`defineTheme`) and changes the
|
|
4
|
+
* accent, surfaces or faces it needs.
|
|
5
|
+
*/
|
|
6
|
+
import { type Theme } from "./tokens";
|
|
7
|
+
/** DRC health and finding severity read the same in every theme (owner decision, PB-894 §5). */
|
|
8
|
+
export declare const DRC_TOKENS: {
|
|
9
|
+
drcConfigured: string;
|
|
10
|
+
drcPartial: string;
|
|
11
|
+
drcIncompatible: string;
|
|
12
|
+
drcUnconfigured: string;
|
|
13
|
+
severityError: string;
|
|
14
|
+
severityWarning: string;
|
|
15
|
+
severityInfo: string;
|
|
16
|
+
severityOk: string;
|
|
17
|
+
};
|
|
18
|
+
/** Domain and signal colours on dark surfaces. */
|
|
19
|
+
export declare const DARK_DATA_TOKENS: {
|
|
20
|
+
domainElectrical: string;
|
|
21
|
+
domainMechanical: string;
|
|
22
|
+
domainPneumatic: string;
|
|
23
|
+
domainHydraulic: string;
|
|
24
|
+
domainThermal: string;
|
|
25
|
+
domainNetwork: string;
|
|
26
|
+
domainSoftware: string;
|
|
27
|
+
domainOther: string;
|
|
28
|
+
signalPower: string;
|
|
29
|
+
signalGround: string;
|
|
30
|
+
signalDigital: string;
|
|
31
|
+
signalAnalog: string;
|
|
32
|
+
signalI2c: string;
|
|
33
|
+
signalSpi: string;
|
|
34
|
+
signalUart: string;
|
|
35
|
+
signalCan: string;
|
|
36
|
+
signalPwm: string;
|
|
37
|
+
signalPhase: string;
|
|
38
|
+
signalRf: string;
|
|
39
|
+
signalOther: string;
|
|
40
|
+
};
|
|
41
|
+
/** The same on light surfaces: one step darker, so thin lines keep their contrast. */
|
|
42
|
+
export declare const LIGHT_DATA_TOKENS: {
|
|
43
|
+
domainElectrical: string;
|
|
44
|
+
domainMechanical: string;
|
|
45
|
+
domainPneumatic: string;
|
|
46
|
+
domainHydraulic: string;
|
|
47
|
+
domainThermal: string;
|
|
48
|
+
domainNetwork: string;
|
|
49
|
+
domainSoftware: string;
|
|
50
|
+
domainOther: string;
|
|
51
|
+
signalPower: string;
|
|
52
|
+
signalGround: string;
|
|
53
|
+
signalDigital: string;
|
|
54
|
+
signalAnalog: string;
|
|
55
|
+
signalI2c: string;
|
|
56
|
+
signalSpi: string;
|
|
57
|
+
signalUart: string;
|
|
58
|
+
signalCan: string;
|
|
59
|
+
signalPwm: string;
|
|
60
|
+
signalPhase: string;
|
|
61
|
+
signalRf: string;
|
|
62
|
+
signalOther: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const defaultDark: Theme;
|
|
65
|
+
export declare const defaultLight: Theme;
|
|
66
|
+
/** The theme a scheme falls back to. */
|
|
67
|
+
export declare const defaultTheme: (scheme?: "dark" | "light") => Theme;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The viewer's theme-token contract: every colour, surface, shadow and face
|
|
3
|
+
* the viewer draws with is one of these semantic tokens, read as a CSS
|
|
4
|
+
* variable (`--uhd-<kebab-name>`). Nothing in the viewer's styles names a raw
|
|
5
|
+
* colour; a host restyles the viewer by giving these tokens values (a theme),
|
|
6
|
+
* never by overriding class rules.
|
|
7
|
+
*
|
|
8
|
+
* A theme is plain data (`Theme`). Values may be any CSS value, including
|
|
9
|
+
* `var(...)` references to the host's own variables (the VS Code adapter maps
|
|
10
|
+
* every token onto `--vscode-*`) and `color-mix(...)` of other tokens.
|
|
11
|
+
*
|
|
12
|
+
* Nothing here names a host product: hosts bring their own themes through
|
|
13
|
+
* `defineTheme` (or a `ThemeAdapter`, ./adapters.ts).
|
|
14
|
+
*/
|
|
15
|
+
/** Every token, grouped as the contract documents them. */
|
|
16
|
+
export interface ThemeTokens {
|
|
17
|
+
/** The page behind everything (the app shell). */
|
|
18
|
+
background: string;
|
|
19
|
+
/** The diagram canvas. */
|
|
20
|
+
canvas: string;
|
|
21
|
+
/** The canvas's dot grid. */
|
|
22
|
+
canvasDot: string;
|
|
23
|
+
/** Panels and floating cards (inspector, legend, toolbars). */
|
|
24
|
+
surface: string;
|
|
25
|
+
/** Popovers, menus and tooltips above a surface. */
|
|
26
|
+
surfaceRaised: string;
|
|
27
|
+
/** Wells inside a surface: inputs, code, table bands, drawing frames. */
|
|
28
|
+
surfaceSunken: string;
|
|
29
|
+
/** Floating chrome laid over the canvas (translucent surface). */
|
|
30
|
+
overlay: string;
|
|
31
|
+
/** Behind a modal view (dims the canvas). */
|
|
32
|
+
scrim: string;
|
|
33
|
+
/** Muted fill (chips, progress tracks). */
|
|
34
|
+
muted: string;
|
|
35
|
+
/** Hover fill on a control or row. */
|
|
36
|
+
hover: string;
|
|
37
|
+
/** Pressed / active fill on a control. */
|
|
38
|
+
active: string;
|
|
39
|
+
/** A module card on the canvas. */
|
|
40
|
+
node: string;
|
|
41
|
+
/** A selected module card. */
|
|
42
|
+
nodeSelected: string;
|
|
43
|
+
/** A group container's fill. */
|
|
44
|
+
group: string;
|
|
45
|
+
/** Behind artifact image previews (most part drawings are made for paper). */
|
|
46
|
+
preview: string;
|
|
47
|
+
/** Behind board drawings (PCB layers). */
|
|
48
|
+
drawing: string;
|
|
49
|
+
text: string;
|
|
50
|
+
textMuted: string;
|
|
51
|
+
textFaint: string;
|
|
52
|
+
/** Text on an accent fill. */
|
|
53
|
+
textOnAccent: string;
|
|
54
|
+
/** A link-like text button. */
|
|
55
|
+
textLink: string;
|
|
56
|
+
border: string;
|
|
57
|
+
borderSubtle: string;
|
|
58
|
+
borderStrong: string;
|
|
59
|
+
/** A module card's outline. */
|
|
60
|
+
nodeBorder: string;
|
|
61
|
+
/** A module card's outline under the pointer. */
|
|
62
|
+
nodeBorderHover: string;
|
|
63
|
+
/** A group container's dashed outline. */
|
|
64
|
+
groupBorder: string;
|
|
65
|
+
/** Extra outline drawn around every control in a high-contrast theme (transparent otherwise). */
|
|
66
|
+
contrastBorder: string;
|
|
67
|
+
/** Outline of the active / selected control in a high-contrast theme (transparent otherwise). */
|
|
68
|
+
contrastActiveBorder: string;
|
|
69
|
+
/** The one accent: selection, active toggles, the focused link. */
|
|
70
|
+
accent: string;
|
|
71
|
+
accentHover: string;
|
|
72
|
+
/** A light wash of the accent (an active tab, a selected row). */
|
|
73
|
+
accentTint: string;
|
|
74
|
+
/** The accent's glow around a selected card. */
|
|
75
|
+
accentGlow: string;
|
|
76
|
+
/** A second highlight, distinct from the accent (a counterpart, an interface). */
|
|
77
|
+
highlight: string;
|
|
78
|
+
/** Keyboard focus outline. */
|
|
79
|
+
focusRing: string;
|
|
80
|
+
/** A selected row's or item's fill. */
|
|
81
|
+
selection: string;
|
|
82
|
+
/** Text on a selected row. */
|
|
83
|
+
selectionText: string;
|
|
84
|
+
domainElectrical: string;
|
|
85
|
+
domainMechanical: string;
|
|
86
|
+
domainPneumatic: string;
|
|
87
|
+
domainHydraulic: string;
|
|
88
|
+
domainThermal: string;
|
|
89
|
+
domainNetwork: string;
|
|
90
|
+
domainSoftware: string;
|
|
91
|
+
/** Items outside the classification's focus (signal mode's other domains). */
|
|
92
|
+
domainOther: string;
|
|
93
|
+
signalPower: string;
|
|
94
|
+
signalGround: string;
|
|
95
|
+
signalDigital: string;
|
|
96
|
+
signalAnalog: string;
|
|
97
|
+
signalI2c: string;
|
|
98
|
+
signalSpi: string;
|
|
99
|
+
signalUart: string;
|
|
100
|
+
signalCan: string;
|
|
101
|
+
signalPwm: string;
|
|
102
|
+
signalPhase: string;
|
|
103
|
+
signalRf: string;
|
|
104
|
+
signalOther: string;
|
|
105
|
+
drcConfigured: string;
|
|
106
|
+
drcPartial: string;
|
|
107
|
+
drcIncompatible: string;
|
|
108
|
+
drcUnconfigured: string;
|
|
109
|
+
severityError: string;
|
|
110
|
+
severityWarning: string;
|
|
111
|
+
severityInfo: string;
|
|
112
|
+
severityOk: string;
|
|
113
|
+
scrollbarThumb: string;
|
|
114
|
+
scrollbarThumbHover: string;
|
|
115
|
+
sceneBackground: string;
|
|
116
|
+
sceneGrid: string;
|
|
117
|
+
sceneGridMinor: string;
|
|
118
|
+
radius: string;
|
|
119
|
+
shadowSm: string;
|
|
120
|
+
shadowMd: string;
|
|
121
|
+
shadowLg: string;
|
|
122
|
+
/** Interface text (labels, buttons, values). */
|
|
123
|
+
fontUi: string;
|
|
124
|
+
/** Display face for headings and card titles. */
|
|
125
|
+
fontLabel: string;
|
|
126
|
+
/** Code, ids and numbers. */
|
|
127
|
+
fontMono: string;
|
|
128
|
+
}
|
|
129
|
+
export type ThemeToken = keyof ThemeTokens;
|
|
130
|
+
/** Light or dark surfaces, and whether the host asks for high contrast. */
|
|
131
|
+
export type ThemeScheme = "dark" | "light" | "high-contrast" | "high-contrast-light";
|
|
132
|
+
export interface Theme {
|
|
133
|
+
/** A stable id (`default-dark`, `vscode`, a host's own). */
|
|
134
|
+
id: string;
|
|
135
|
+
/** For people choosing a theme. */
|
|
136
|
+
label: string;
|
|
137
|
+
scheme: ThemeScheme;
|
|
138
|
+
tokens: ThemeTokens;
|
|
139
|
+
}
|
|
140
|
+
/** The CSS variable of a token: `textMuted` → `--uhd-text-muted`. */
|
|
141
|
+
export declare const tokenVar: (token: ThemeToken) => string;
|
|
142
|
+
/** `var(--uhd-…)` for a token, to use in inline styles and SVG attributes. */
|
|
143
|
+
export declare const token: (name: ThemeToken) => string;
|
|
144
|
+
/** Every token name, in contract order (used by tests, adapters and docs). */
|
|
145
|
+
export declare const TOKEN_NAMES: readonly ThemeToken[];
|
|
146
|
+
/** A wash of another token: `mix("accent", 15)` is the accent at 15 % over transparent. */
|
|
147
|
+
export declare const mix: (name: ThemeToken, percent: number, over?: string) => string;
|
|
148
|
+
/**
|
|
149
|
+
* Tokens that follow from others unless a theme sets them: the accent's tint
|
|
150
|
+
* and glow, hover and active washes of the text colour, the selection. A
|
|
151
|
+
* theme that sets only the accent still gets a coherent set.
|
|
152
|
+
*/
|
|
153
|
+
export declare const DERIVED: Partial<ThemeTokens>;
|
|
154
|
+
/**
|
|
155
|
+
* A complete theme from a base and the tokens that change. Derived tokens
|
|
156
|
+
* (DERIVED) are recomputed from the result unless `tokens` sets them.
|
|
157
|
+
*/
|
|
158
|
+
export declare function defineTheme(base: Theme, change: {
|
|
159
|
+
id: string;
|
|
160
|
+
label: string;
|
|
161
|
+
scheme?: ThemeScheme;
|
|
162
|
+
tokens?: Partial<ThemeTokens>;
|
|
163
|
+
}): Theme;
|
|
164
|
+
/** The CSS declarations of a theme (`--uhd-x: value;` …), for a stylesheet or an inline style. */
|
|
165
|
+
export declare function themeDeclarations(theme: Theme): string;
|
|
166
|
+
/** A stylesheet rule applying a theme under `selector`. */
|
|
167
|
+
export declare const themeCss: (theme: Theme, selector?: string) => string;
|
|
168
|
+
/**
|
|
169
|
+
* Applies a theme to an element: every token as an inline CSS variable, and
|
|
170
|
+
* `data-uhd-theme` / `data-uhd-scheme` for rules that differ by scheme (high
|
|
171
|
+
* contrast draws thicker outlines). Returns a function that removes it.
|
|
172
|
+
*/
|
|
173
|
+
export declare function applyTheme(element: HTMLElement, theme: Theme): () => void;
|
|
174
|
+
/** A token's resolved value on an element (for canvases that cannot read CSS: the 3D scene). */
|
|
175
|
+
export declare function readToken(element: Element, name: ThemeToken): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base inspector primitives: a panel with a header and a scrolling body,
|
|
3
|
+
* titled sections, key/value rows, badges and status dots. Shells build their
|
|
4
|
+
* inspectors (and hosts their native-looking side views) from these.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
export interface InspectorPanelProps {
|
|
8
|
+
/** The header's title ("Inspector", a module's name). */
|
|
9
|
+
title?: ReactNode;
|
|
10
|
+
/** Icon buttons or tabs at the header's right. */
|
|
11
|
+
actions?: ReactNode;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Classes of the scrolled content. */
|
|
15
|
+
bodyClassName?: string;
|
|
16
|
+
}
|
|
17
|
+
/** A panel: header, then a body that scrolls with the themed scrollbar. */
|
|
18
|
+
export declare function InspectorPanel({ title, actions, children, className, bodyClassName }: InspectorPanelProps): import("react").JSX.Element;
|
|
19
|
+
export declare function Section({ title, count, actions, children }: {
|
|
20
|
+
title: ReactNode;
|
|
21
|
+
count?: number;
|
|
22
|
+
actions?: ReactNode;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}): import("react").JSX.Element;
|
|
25
|
+
/** A key and its value on one line (nothing when the value is empty). */
|
|
26
|
+
export declare function PropertyRow({ name, value, mono }: {
|
|
27
|
+
name: ReactNode;
|
|
28
|
+
value?: ReactNode;
|
|
29
|
+
mono?: boolean;
|
|
30
|
+
}): import("react").JSX.Element | null;
|
|
31
|
+
export type Tone = "neutral" | "accent" | "ok" | "warning" | "error" | "info";
|
|
32
|
+
export declare function Badge({ tone, children }: {
|
|
33
|
+
tone?: Tone;
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
}): import("react").JSX.Element;
|
|
36
|
+
export declare function StatusDot({ tone, label }: {
|
|
37
|
+
tone?: Tone;
|
|
38
|
+
label?: string;
|
|
39
|
+
}): import("react").JSX.Element;
|
|
40
|
+
/** A quiet message where a panel has nothing to show yet. */
|
|
41
|
+
export declare function EmptyState({ icon, title, children }: {
|
|
42
|
+
icon?: ReactNode;
|
|
43
|
+
title: ReactNode;
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legend primitives: a floating card with a title and swatches. A swatch is
|
|
3
|
+
* a short line (links) or a dot (states). An item given `onSelect` is a
|
|
4
|
+
* button: the legend then isolates what it stands for. A compact item is
|
|
5
|
+
* its swatch alone, named by its label (`LegendSwatches` lays them out).
|
|
6
|
+
*/
|
|
7
|
+
import type { HTMLAttributes, ReactNode, Ref } from "react";
|
|
8
|
+
export interface LegendProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
9
|
+
title?: ReactNode;
|
|
10
|
+
ref?: Ref<HTMLDivElement>;
|
|
11
|
+
/** As narrow as its content (a compact legend of swatches); else at least 150 px. */
|
|
12
|
+
compact?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function Legend({ title, children, className, compact, ...rest }: LegendProps): import("react").JSX.Element;
|
|
15
|
+
export interface LegendItemProps {
|
|
16
|
+
color: string;
|
|
17
|
+
label: ReactNode;
|
|
18
|
+
shape?: "line" | "dot" | "dash";
|
|
19
|
+
/** Given: the item is a button. `add` says a modifier key was held (add to, or take from, the ones held). */
|
|
20
|
+
onSelect?: (add: boolean) => void;
|
|
21
|
+
/** The item is the one (or one of those) isolated. */
|
|
22
|
+
pressed?: boolean;
|
|
23
|
+
/** Another item is isolated: this one steps back. */
|
|
24
|
+
dimmed?: boolean;
|
|
25
|
+
/** Nothing here is of this kind: the button is disabled and says so. */
|
|
26
|
+
absent?: boolean;
|
|
27
|
+
/** The button's tooltip. */
|
|
28
|
+
hint?: string;
|
|
29
|
+
/** A second line of the tooltip (how to hold several). */
|
|
30
|
+
hintShortcut?: string;
|
|
31
|
+
/** The swatch alone (a narrow legend): the label names the button and is its tooltip. */
|
|
32
|
+
compact?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function LegendItem({ color, label, shape, onSelect, pressed, dimmed, absent, hint, hintShortcut, compact }: LegendItemProps): import("react").JSX.Element;
|
|
35
|
+
/** Compact items side by side, `columns` to a row: a legend as narrow as its swatches. */
|
|
36
|
+
export declare function LegendSwatches({ columns, children, label }: {
|
|
37
|
+
columns?: number;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
label?: string;
|
|
40
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface ScrollAreaProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Classes of the root. It is a flex column, so a height (a flex child with
|
|
6
|
+
* min-h-0) or a max height (`max-h-64`) is all the scrolled viewport needs.
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Classes of the scrolled viewport's content wrapper. */
|
|
10
|
+
contentClassName?: string;
|
|
11
|
+
/** Which bars to offer (default vertical). */
|
|
12
|
+
axis?: "vertical" | "horizontal" | "both";
|
|
13
|
+
/** `hover` shows the bars while the pointer is over the area; `scroll` only while scrolling (default hover). */
|
|
14
|
+
type?: "hover" | "scroll" | "auto" | "always";
|
|
15
|
+
}
|
|
16
|
+
export declare const ScrollArea: import("react").ForwardRefExoticComponent<ScrollAreaProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar primitives: a floating card of icon buttons, each naming itself in
|
|
3
|
+
* a tooltip (no text toolbars). Toggles show their state with an accent wash,
|
|
4
|
+
* an accent outline and `aria-pressed`; a high-contrast theme outlines them
|
|
5
|
+
* instead.
|
|
6
|
+
*/
|
|
7
|
+
import { type ButtonHTMLAttributes, type ReactNode } from "react";
|
|
8
|
+
export interface ToolbarProps {
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
orientation?: "horizontal" | "vertical";
|
|
12
|
+
/** For assistive technology ("Diagram tools"). */
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
/** A floating card holding icon buttons and separators. */
|
|
16
|
+
export declare function Toolbar({ children, className, orientation, label }: ToolbarProps): import("react").JSX.Element;
|
|
17
|
+
export declare function ToolbarSeparator({ orientation }: {
|
|
18
|
+
orientation?: "vertical" | "horizontal";
|
|
19
|
+
}): import("react").JSX.Element;
|
|
20
|
+
export interface IconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
21
|
+
/** A Lucide icon name (kebab-case), or the icon itself. */
|
|
22
|
+
icon: string | ReactNode;
|
|
23
|
+
/** What the button does: its tooltip and accessible name. */
|
|
24
|
+
label: string;
|
|
25
|
+
/** A toggle's state (absent: a plain action). */
|
|
26
|
+
pressed?: boolean;
|
|
27
|
+
shortcut?: string;
|
|
28
|
+
tooltipSide?: "top" | "bottom" | "left" | "right";
|
|
29
|
+
size?: "sm" | "md";
|
|
30
|
+
/** A count or dot over the icon (errors on a checks button). */
|
|
31
|
+
badge?: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
34
|
+
export interface ToggleGroupProps<T extends string> {
|
|
35
|
+
/** The choices, each an icon with a label for its tooltip. */
|
|
36
|
+
options: readonly {
|
|
37
|
+
id: T;
|
|
38
|
+
icon: string | ReactNode;
|
|
39
|
+
label: string;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
}[];
|
|
42
|
+
value: T;
|
|
43
|
+
onChange: (value: T) => void;
|
|
44
|
+
label?: string;
|
|
45
|
+
tooltipSide?: IconButtonProps["tooltipSide"];
|
|
46
|
+
size?: IconButtonProps["size"];
|
|
47
|
+
}
|
|
48
|
+
/** One of several, as icon buttons side by side. */
|
|
49
|
+
export declare function ToggleGroup<T extends string>({ options, value, onChange, label, tooltipSide, size }: ToggleGroupProps<T>): import("react").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of the diagram's legend fits beside the bottom toolbar. The legend
|
|
3
|
+
* stays where it is (bottom left) and gives way as the toolbar comes near:
|
|
4
|
+
* the full card, then a compact one (swatches without their labels), then,
|
|
5
|
+
* at its smallest, a button in the toolbar that opens it. No DOM here: the
|
|
6
|
+
* legend measures, this decides.
|
|
7
|
+
*/
|
|
8
|
+
export type LegendStage = "full" | "compact" | "button";
|
|
9
|
+
/** Space kept between the legend and the toolbar (px). */
|
|
10
|
+
export declare const LEGEND_GAP = 8;
|
|
11
|
+
/** A larger form comes back only with this much room to spare (px), so a width at the edge does not flicker between two. */
|
|
12
|
+
export declare const LEGEND_HYSTERESIS = 6;
|
|
13
|
+
export interface Box {
|
|
14
|
+
left: number;
|
|
15
|
+
top: number;
|
|
16
|
+
right: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
}
|
|
19
|
+
export interface LegendMeasure {
|
|
20
|
+
/** Where the legend's left edge is (the same for every form). */
|
|
21
|
+
left: number;
|
|
22
|
+
/** Each form's box, as it would sit (bottom left). */
|
|
23
|
+
full: Box;
|
|
24
|
+
compact: Box;
|
|
25
|
+
/** The toolbar's box, or none (no toolbar, or hidden). */
|
|
26
|
+
toolbar?: Box | null;
|
|
27
|
+
/** The legend's button in the toolbar takes this much of it (its width and gap), when it is there: the toolbar is measured as if it were not. */
|
|
28
|
+
slot?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The room the legend has before the toolbar (px): from its left edge to
|
|
32
|
+
* the toolbar's, less the gap. The toolbar is centred, so its button for the
|
|
33
|
+
* legend moves its left edge by half the button: that half is given back,
|
|
34
|
+
* and the room is the same whether or not the button is in it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function legendRoom(m: Pick<LegendMeasure, "left" | "toolbar" | "slot">): number;
|
|
37
|
+
/**
|
|
38
|
+
* The largest form that does not run into the toolbar. A form fits when it is
|
|
39
|
+
* clear of the toolbar's height, or narrower than the room. Moving up to a
|
|
40
|
+
* larger form than `current` takes `LEGEND_HYSTERESIS` more.
|
|
41
|
+
*/
|
|
42
|
+
export declare function legendStage(m: LegendMeasure, current?: LegendStage): LegendStage;
|