@deltarobotics/uhd-viewer 0.0.0-stage → 0.2.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/CHANGELOG.md +74 -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-CEJyT8hF.css +2 -0
- package/dist/app/assets/index-DWZ-48wc.js +3853 -0
- package/dist/app/index.html +16 -0
- package/dist/components/components.css +6372 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +26609 -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 +30 -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 +90 -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 +55 -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 +126 -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 +66 -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 +128 -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 +101 -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 +41 -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 +58 -0
- package/dist/components/types/uhd-viewer/src/model/hierarchy.d.ts +173 -0
- package/dist/components/types/uhd-viewer/src/model/isolate.d.ts +33 -0
- package/dist/components/types/uhd-viewer/src/model/level.d.ts +7 -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 +184 -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 +59 -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 +55 -0
- package/dist/components/types/uhd-viewer/src/viewer/controller.d.ts +219 -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 +82 -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 +187 -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 +97787 -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,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,59 @@
|
|
|
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. An item with a
|
|
5
|
+
* `meaning` reads as two lines, its name and what it stands for. A compact
|
|
6
|
+
* item is its swatch alone, named by its label (`LegendSwatches` lays them
|
|
7
|
+
* out). Folded, a legend is a tab at the right edge (`LegendTab`): a chevron
|
|
8
|
+
* and a dot per colour.
|
|
9
|
+
*/
|
|
10
|
+
import type { ButtonHTMLAttributes, HTMLAttributes, ReactNode, Ref } from "react";
|
|
11
|
+
export interface LegendProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
12
|
+
title?: ReactNode;
|
|
13
|
+
ref?: Ref<HTMLDivElement>;
|
|
14
|
+
/** As narrow as its content (a compact legend of swatches); else at least 150 px. */
|
|
15
|
+
compact?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function Legend({ title, children, className, compact, ...rest }: LegendProps): import("react").JSX.Element;
|
|
18
|
+
export interface LegendItemProps {
|
|
19
|
+
color: string;
|
|
20
|
+
label: ReactNode;
|
|
21
|
+
shape?: "line" | "dot" | "dash";
|
|
22
|
+
/** Given: the item is a button. `add` says a modifier key was held (add to, or take from, the ones held). */
|
|
23
|
+
onSelect?: (add: boolean) => void;
|
|
24
|
+
/** The item is the one (or one of those) isolated. */
|
|
25
|
+
pressed?: boolean;
|
|
26
|
+
/** Another item is isolated: this one steps back. */
|
|
27
|
+
dimmed?: boolean;
|
|
28
|
+
/** Nothing here is of this kind: the button is disabled and says so. */
|
|
29
|
+
absent?: boolean;
|
|
30
|
+
/** The button's tooltip. */
|
|
31
|
+
hint?: string;
|
|
32
|
+
/** A second line of the tooltip (how to hold several). */
|
|
33
|
+
hintShortcut?: string;
|
|
34
|
+
/** The swatch alone (a narrow legend): the label names the button and is its tooltip. */
|
|
35
|
+
compact?: boolean;
|
|
36
|
+
/** What the entry stands for, in a few words: a second, muted line under the label. */
|
|
37
|
+
meaning?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function LegendItem({ color, label, shape, onSelect, pressed, dimmed, absent, hint, hintShortcut, compact, meaning }: LegendItemProps): import("react").JSX.Element;
|
|
40
|
+
/** Compact items side by side, `columns` to a row: a legend as narrow as its swatches. */
|
|
41
|
+
export declare function LegendSwatches({ columns, children, label }: {
|
|
42
|
+
columns?: number;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
label?: string;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
export interface LegendTabProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
47
|
+
/** A dot per colour the legend explains (`dimmed`: it steps back, as an entry does while another is isolated). */
|
|
48
|
+
dots: {
|
|
49
|
+
key: string;
|
|
50
|
+
color: string;
|
|
51
|
+
dimmed?: boolean;
|
|
52
|
+
}[];
|
|
53
|
+
ref?: Ref<HTMLButtonElement>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A folded legend: a narrow tab at the right edge, a chevron and the
|
|
57
|
+
* colours it explains as dots. A click opens the legend; its label names it.
|
|
58
|
+
*/
|
|
59
|
+
export declare function LegendTab({ dots, className, ...rest }: LegendTabProps): 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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of the diagram's legend fits beside the bottom toolbar. The legend
|
|
3
|
+
* stays where it is (bottom right) 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. Folded, it is a
|
|
6
|
+
* narrow tab at the right edge, which gives way to the button the same way.
|
|
7
|
+
* A short canvas folds it (`legendShort`). No DOM here: the legend measures,
|
|
8
|
+
* this decides.
|
|
9
|
+
*/
|
|
10
|
+
export type LegendStage = "full" | "compact" | "button";
|
|
11
|
+
/** Space kept between the legend and the toolbar (px). */
|
|
12
|
+
export declare const LEGEND_GAP = 8;
|
|
13
|
+
/** A larger form comes back only with this much room to spare (px), so a width at the edge does not flicker between two. */
|
|
14
|
+
export declare const LEGEND_HYSTERESIS = 6;
|
|
15
|
+
/** Below this canvas height (px) the legend folds by itself: open, it would cover much of the drawing. */
|
|
16
|
+
export declare const LEGEND_SHORT = 500;
|
|
17
|
+
export interface Box {
|
|
18
|
+
left: number;
|
|
19
|
+
top: number;
|
|
20
|
+
right: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
}
|
|
23
|
+
export interface LegendMeasure {
|
|
24
|
+
/** Where the legend's right edge is (the same for every form). */
|
|
25
|
+
right: number;
|
|
26
|
+
/** Each form's box, as it would sit (bottom right). */
|
|
27
|
+
full: Box;
|
|
28
|
+
compact: Box;
|
|
29
|
+
/** The folded tab's box, as it would sit (at the right edge). */
|
|
30
|
+
tab?: Box;
|
|
31
|
+
/** The toolbar's box, or none (no toolbar, or hidden). */
|
|
32
|
+
toolbar?: Box | null;
|
|
33
|
+
/** 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. */
|
|
34
|
+
slot?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The room the legend has before the toolbar (px): from the toolbar's right
|
|
38
|
+
* edge to the legend's, less the gap. The toolbar is centred, so its button
|
|
39
|
+
* for the legend moves its right edge by half the button: that half is taken
|
|
40
|
+
* back, and the room is the same whether or not the button is in it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function legendRoom(m: Pick<LegendMeasure, "right" | "toolbar" | "slot">): number;
|
|
43
|
+
/**
|
|
44
|
+
* The largest form that does not run into the toolbar. A form fits when it is
|
|
45
|
+
* clear of the toolbar's height, or narrower than the room. Moving up to a
|
|
46
|
+
* larger form than `current` takes `LEGEND_HYSTERESIS` more. Folded
|
|
47
|
+
* (`folded`), the tab is the only form: "full" while it fits, else "button".
|
|
48
|
+
*/
|
|
49
|
+
export declare function legendStage(m: LegendMeasure, current?: LegendStage, folded?: boolean): LegendStage;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the legend shows folded: the user folded it, or the canvas is
|
|
52
|
+
* shorter than `LEGEND_SHORT` and the user has not opened it since it became
|
|
53
|
+
* so (`peek`).
|
|
54
|
+
*/
|
|
55
|
+
export declare function legendFolded(open: boolean, canvasHeight: number, peek: boolean): boolean;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { Component, type ErrorInfo, type ReactNode } from "react";
|
|
2
|
+
import type { ChildLink } from "@deltarobotics/uhd";
|
|
3
|
+
import type { UhdBundleDiagnostic } from "@deltarobotics/uhd";
|
|
4
|
+
import type { Classification } from "../model/classification";
|
|
5
|
+
import type { ViewLink } from "../model/types";
|
|
6
|
+
import { type ComputedLayout, type LevelLayout, type LinkLayout } from "../layout/layout";
|
|
7
|
+
import type { Pt } from "../canvas/routing";
|
|
8
|
+
import { type LoadedSource } from "../source/source";
|
|
9
|
+
import type { ViewerEvent, ViewerOptions, ViewerSelection } from "../api";
|
|
10
|
+
import type { Selection, ViewCommand } from "../canvas/Canvas";
|
|
11
|
+
import { type CanvasTool, type Viewport } from "../canvas/interaction";
|
|
12
|
+
import type { Goto, NodeMenuItem, Panel } from "../chrome/Chrome";
|
|
13
|
+
import type { CadSelection } from "../cad/CadView";
|
|
14
|
+
import type { LegendStage } from "../ui/legendFit";
|
|
15
|
+
import type { CommandBus } from "../host/channel";
|
|
16
|
+
import { type HostActions } from "../host/context";
|
|
17
|
+
type Overrides = Record<string, ChildLink[]>;
|
|
18
|
+
/** What is being dragged right now (see LiveLayout). */
|
|
19
|
+
export interface Live {
|
|
20
|
+
nodes?: Set<string>;
|
|
21
|
+
links?: Set<string>;
|
|
22
|
+
}
|
|
23
|
+
export interface AppProps extends ViewerOptions {
|
|
24
|
+
/** Development only: absolute artifact bases are served through Vite's /@fs route. */
|
|
25
|
+
fsRoute?: boolean;
|
|
26
|
+
/** The host channel (mount.tsx): its messages, where events go, and which open actions the host takes. */
|
|
27
|
+
host?: HostLink;
|
|
28
|
+
}
|
|
29
|
+
export interface HostLink {
|
|
30
|
+
bus: CommandBus;
|
|
31
|
+
emit: (event: ViewerEvent) => void;
|
|
32
|
+
/** The host opens sources (the viewer offers OPEN SOURCE). */
|
|
33
|
+
source: boolean;
|
|
34
|
+
/** The host opens artifact files (instead of a new tab). */
|
|
35
|
+
artifact: boolean;
|
|
36
|
+
/** The host opens modules on their own (double-click), `onOpenModule`. */
|
|
37
|
+
module?: boolean;
|
|
38
|
+
/** The host shows the pair view (instead of the viewer's own over the diagram). */
|
|
39
|
+
pair?: boolean;
|
|
40
|
+
/** The host has an inspector of its own and shows a module there when asked (`onInspect`). */
|
|
41
|
+
inspect?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Loads the UHD bundle (the viewer's only input): the source once loaded, or why not. */
|
|
44
|
+
export declare function useViewerSource(props: Pick<AppProps, "bundle" | "bundleUrl" | "resolveArtifact" | "fsRoute">): {
|
|
45
|
+
source: LoadedSource | null;
|
|
46
|
+
error: string | null;
|
|
47
|
+
empty: boolean;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The viewer's state and behaviour for one loaded bundle: what is drawn, what
|
|
51
|
+
* is selected, the drill level, the classification, layout edits, the host
|
|
52
|
+
* channel. Shells read it through `useViewer()` inside `UhdViewer`; the
|
|
53
|
+
* canvases, inspector panels, toolbar and legend are views of it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function useViewerController(source: LoadedSource, options: ViewerOptions, host?: HostLink): {
|
|
56
|
+
source: LoadedSource;
|
|
57
|
+
options: ViewerOptions;
|
|
58
|
+
scenario: import("../source/source").ViewerScenario;
|
|
59
|
+
scenarios: {
|
|
60
|
+
id: string;
|
|
61
|
+
label: string;
|
|
62
|
+
}[];
|
|
63
|
+
onScenario: (id: string) => void;
|
|
64
|
+
system: import("@deltarobotics/uhd").ModuleDef;
|
|
65
|
+
vm: import("../components").ViewModel;
|
|
66
|
+
drawn: import("../components").ViewModel;
|
|
67
|
+
layout: ComputedLayout;
|
|
68
|
+
hand: LevelLayout;
|
|
69
|
+
levelKey: string;
|
|
70
|
+
levelDef: import("@deltarobotics/uhd").ModuleDef;
|
|
71
|
+
drill: string[];
|
|
72
|
+
topLevel: boolean;
|
|
73
|
+
diagnostics: import("../model/diagnostics").ScopedDiagnostic[];
|
|
74
|
+
hostDiagnostics: UhdBundleDiagnostic[];
|
|
75
|
+
errors: number;
|
|
76
|
+
defFor: (id?: string) => import("@deltarobotics/uhd").ModuleDef | undefined;
|
|
77
|
+
bSlotsFor: (link: ViewLink) => string[];
|
|
78
|
+
view: "3d" | "diagram";
|
|
79
|
+
setView: import("react").Dispatch<import("react").SetStateAction<"3d" | "diagram">>;
|
|
80
|
+
mode: Classification;
|
|
81
|
+
setMode: (m: Classification) => void;
|
|
82
|
+
conductors: boolean;
|
|
83
|
+
setConductors: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
84
|
+
showGrounds: boolean;
|
|
85
|
+
setShowGrounds: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
86
|
+
isolated: ReadonlySet<string>;
|
|
87
|
+
isolation: import("../components").Isolation | null;
|
|
88
|
+
present: Set<string>;
|
|
89
|
+
onIsolate: (key: string, add?: boolean) => void;
|
|
90
|
+
clearIsolated: () => void;
|
|
91
|
+
legendStage: LegendStage;
|
|
92
|
+
setLegendStage: import("react").Dispatch<import("react").SetStateAction<LegendStage>>;
|
|
93
|
+
panel: Panel | null;
|
|
94
|
+
setPanel: import("react").Dispatch<import("react").SetStateAction<Panel | null>>;
|
|
95
|
+
selection: Selection;
|
|
96
|
+
setSelection: (s: Selection) => void;
|
|
97
|
+
group: readonly string[];
|
|
98
|
+
onSelectChanges: (changes: readonly {
|
|
99
|
+
id: string;
|
|
100
|
+
selected: boolean;
|
|
101
|
+
}[]) => void;
|
|
102
|
+
onSelectAll: () => void;
|
|
103
|
+
onEscape: () => void;
|
|
104
|
+
interaction: import("../components").InteractionState;
|
|
105
|
+
onInteraction: import("react").ActionDispatch<[action: import("../components").InteractionAction]>;
|
|
106
|
+
tool: CanvasTool;
|
|
107
|
+
setTool: (tool: CanvasTool) => void;
|
|
108
|
+
viewCommand: ViewCommand | undefined;
|
|
109
|
+
fitView: () => void;
|
|
110
|
+
zoomIn: () => void;
|
|
111
|
+
zoomOut: () => void;
|
|
112
|
+
viewport: Viewport | undefined;
|
|
113
|
+
/** Counts the times a host replaced the viewports: the canvas opens again on them. */
|
|
114
|
+
viewportsSeq: number;
|
|
115
|
+
onViewport: (v: Viewport | null) => void;
|
|
116
|
+
openLinks: Set<string>;
|
|
117
|
+
overrides: Overrides;
|
|
118
|
+
pair: ViewLink | undefined;
|
|
119
|
+
setPairLink: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
120
|
+
onNavigate: (depth: number) => void;
|
|
121
|
+
onDrill: (id: string) => void;
|
|
122
|
+
onGoto: (g: Goto) => void;
|
|
123
|
+
onPair: (l: ViewLink) => void;
|
|
124
|
+
onReset: () => void;
|
|
125
|
+
onToggleLink: (id: string) => void;
|
|
126
|
+
onToggleExpand: (id: string) => void;
|
|
127
|
+
onMove: (id: string, x: number, y: number) => void;
|
|
128
|
+
onOverride: (linkId: string, childLinks: ChildLink[] | null) => void;
|
|
129
|
+
editLink: (linkId: string, patch: LinkLayout) => void;
|
|
130
|
+
onPins: (linkId: string, pins: Pt[]) => void;
|
|
131
|
+
setLive: import("react").Dispatch<import("react").SetStateAction<Live | null>>;
|
|
132
|
+
centre: {
|
|
133
|
+
id: string;
|
|
134
|
+
seq: number;
|
|
135
|
+
lines?: readonly string[];
|
|
136
|
+
} | undefined;
|
|
137
|
+
reveal: {
|
|
138
|
+
selection: NonNullable<Selection>;
|
|
139
|
+
seq: number;
|
|
140
|
+
} | undefined;
|
|
141
|
+
cadFocus: {
|
|
142
|
+
path: string;
|
|
143
|
+
seq: number;
|
|
144
|
+
kind?: "node" | "link" | "none";
|
|
145
|
+
look?: boolean;
|
|
146
|
+
} | undefined;
|
|
147
|
+
onCadSelect: (s: CadSelection) => void;
|
|
148
|
+
cadSelection: ViewerSelection | null;
|
|
149
|
+
focusPath: (path: string) => void;
|
|
150
|
+
hostActions: HostActions;
|
|
151
|
+
onOpenNode: (id: string) => void;
|
|
152
|
+
onNodeContext: (id: string, x: number, y: number) => void;
|
|
153
|
+
onPaneContext: (x: number, y: number) => void;
|
|
154
|
+
menu: {
|
|
155
|
+
id?: string;
|
|
156
|
+
x: number;
|
|
157
|
+
y: number;
|
|
158
|
+
} | null;
|
|
159
|
+
menuItems: NodeMenuItem[];
|
|
160
|
+
closeMenu: () => void;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* What a double-click on a node does: `open` it on its own (the host's new
|
|
164
|
+
* tab), `expand` it in place, or `none`. Only a module that holds modules
|
|
165
|
+
* has a level to open or to expand; a part with nothing inside, a net's
|
|
166
|
+
* junction, a rail's tap and a boundary port have none.
|
|
167
|
+
*/
|
|
168
|
+
export declare function openAction(node: {
|
|
169
|
+
defId?: string;
|
|
170
|
+
childCount?: number;
|
|
171
|
+
net?: unknown;
|
|
172
|
+
tapOf?: string;
|
|
173
|
+
sheetPort?: unknown;
|
|
174
|
+
} | undefined, hostOpens: boolean): "open" | "expand" | "none";
|
|
175
|
+
/** Everything a view of the loaded model reads (see useViewerController). */
|
|
176
|
+
export type ViewerController = ReturnType<typeof useViewerController>;
|
|
177
|
+
/** The viewer's state, inside `UhdViewer` (or `ViewerProvider`). */
|
|
178
|
+
export declare function useViewer(): ViewerController;
|
|
179
|
+
/** The viewer's state for a loaded source, for the components inside. */
|
|
180
|
+
export declare function ViewerProvider({ source, options, host, children }: {
|
|
181
|
+
source: LoadedSource;
|
|
182
|
+
options: ViewerOptions;
|
|
183
|
+
host?: HostLink;
|
|
184
|
+
children?: ReactNode;
|
|
185
|
+
}): import("react").JSX.Element;
|
|
186
|
+
export interface UhdViewerProps extends AppProps {
|
|
187
|
+
/** The views of the model: canvases, panels, the shell's own chrome. */
|
|
188
|
+
children?: ReactNode;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Loads the bundle, then provides the viewer's state to `children`. While
|
|
192
|
+
* loading, or when the bundle cannot be read, it says so in place.
|
|
193
|
+
*/
|
|
194
|
+
export declare function UhdViewer({ children, ...props }: UhdViewerProps): import("react").JSX.Element;
|
|
195
|
+
/**
|
|
196
|
+
* A bundle the viewer cannot draw says so in place, instead of leaving an
|
|
197
|
+
* empty page: what failed, and that the next bundle is tried again (a
|
|
198
|
+
* producer that rebuilds on a source edit sends one).
|
|
199
|
+
*/
|
|
200
|
+
export declare class ViewerBoundary extends Component<{
|
|
201
|
+
source: LoadedSource;
|
|
202
|
+
children?: ReactNode;
|
|
203
|
+
}, {
|
|
204
|
+
failed?: {
|
|
205
|
+
source: LoadedSource;
|
|
206
|
+
message: string;
|
|
207
|
+
};
|
|
208
|
+
}> {
|
|
209
|
+
state: {
|
|
210
|
+
failed?: {
|
|
211
|
+
source: LoadedSource;
|
|
212
|
+
message: string;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
216
|
+
static getDerivedStateFromError(): null;
|
|
217
|
+
render(): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
218
|
+
}
|
|
219
|
+
export {};
|