@f-ewald/components 1.41.0 → 1.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/custom-elements.json +1228 -33
- package/dist/dag-graph.d.ts +161 -0
- package/dist/dag-graph.d.ts.map +1 -0
- package/dist/dag-graph.js +724 -0
- package/dist/dag-graph.js.map +1 -0
- package/dist/icons.d.ts +16 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +16 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tokens.css +4 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +10 -0
- package/dist/tokens.js.map +1 -1
- package/dist/utils/dag-layout.d.ts +60 -0
- package/dist/utils/dag-layout.d.ts.map +1 -0
- package/dist/utils/dag-layout.js +80 -0
- package/dist/utils/dag-layout.js.map +1 -0
- package/docs/dag-graph.md +101 -0
- package/docs/design-language.md +4 -1
- package/docs/icons.md +8 -0
- package/llms.txt +57 -0
- package/package.json +2 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type SVGTemplateResult } from "lit";
|
|
2
|
+
import "./icon-button.js";
|
|
3
|
+
import { type DagDirection } from "./utils/dag-layout.js";
|
|
4
|
+
export type { DagDirection } from "./utils/dag-layout.js";
|
|
5
|
+
/** One node of a `dag-graph`. */
|
|
6
|
+
export interface DagNode {
|
|
7
|
+
/** Unique id, referenced by edges and by `selected`. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Text shown on the node; long labels are shortened with an ellipsis (the full text is the tooltip). */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Key into `kinds`, which supplies the node's icon, color, and border style. */
|
|
12
|
+
kind?: string;
|
|
13
|
+
/** Draws the node faded with a dotted border, e.g. for data that is incomplete or unavailable. */
|
|
14
|
+
muted?: boolean;
|
|
15
|
+
/** Emphasizes the node, e.g. as part of a highlighted path or cycle. */
|
|
16
|
+
highlighted?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** One directed edge of a `dag-graph`, pointing from `source` to `target`. */
|
|
19
|
+
export interface DagEdge {
|
|
20
|
+
source: string;
|
|
21
|
+
target: string;
|
|
22
|
+
/** Emphasizes the edge, e.g. as part of a highlighted path or cycle. */
|
|
23
|
+
highlighted?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Presentation of one node kind. */
|
|
26
|
+
export interface DagNodeKind {
|
|
27
|
+
/** Name shown in the legend and appended to the node tooltip. */
|
|
28
|
+
label?: string;
|
|
29
|
+
/** Accent color (any CSS color) for the icon and border; defaults to `--ui-primary`. */
|
|
30
|
+
color?: string;
|
|
31
|
+
/** Icon factory, called with the icon size in pixels — e.g. one of the package's `icon*` exports. */
|
|
32
|
+
icon?: (size: number) => SVGTemplateResult;
|
|
33
|
+
/** Draws the node with a dashed border. */
|
|
34
|
+
dashed?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** A built-in toolbar control: `zoom` (in and out), `fit`, `center` (on the selected node), or `direction`. */
|
|
37
|
+
export type DagControl = "zoom" | "fit" | "center" | "direction";
|
|
38
|
+
/** Detail of the `direction-change` event. */
|
|
39
|
+
export interface DagDirectionChangeDetail {
|
|
40
|
+
direction: DagDirection;
|
|
41
|
+
}
|
|
42
|
+
/** Detail of the `node-select` event. */
|
|
43
|
+
export interface DagNodeSelectDetail {
|
|
44
|
+
id: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Interactive layered drawing of a directed graph — dependencies, pipelines, or any node-link data.
|
|
48
|
+
*
|
|
49
|
+
* Nodes are placed in layers (via dagre) so edges flow left to right (or top to bottom with
|
|
50
|
+
* `direction="TB"`); cycles are allowed, and the edges closing them are drawn dashed and point backward.
|
|
51
|
+
* Each node is a compact card sized to its label, with an optional icon, color, and border style from
|
|
52
|
+
* `kinds`. The whole graph is shown when it fits at a readable zoom; otherwise the selected node is centered at
|
|
53
|
+
* 100%. Drag to pan; pinch or Ctrl/⌘ + wheel to zoom (a plain wheel scrolls the page). With keyboard
|
|
54
|
+
* focus on the graph, arrow keys pan, `+`/`-` zoom, and `0` fits the graph. Clicking a node, or pressing
|
|
55
|
+
* Enter/Space on it, selects it. A toolbar in the top-right corner offers the `controls` you enable.
|
|
56
|
+
*
|
|
57
|
+
* Set `static` to present a fixed picture: the graph is always fitted into view, panning and zooming
|
|
58
|
+
* are off, and the toolbar is hidden; nodes can still be selected.
|
|
59
|
+
*
|
|
60
|
+
* Colors can be changed with these custom properties: `--dag-node-background`, `--dag-node-text`,
|
|
61
|
+
* `--dag-edge-color`, `--dag-selected-color`, and `--dag-highlight-color`; `--dag-graph-height` sets the
|
|
62
|
+
* height (default `24rem`).
|
|
63
|
+
*
|
|
64
|
+
* @element dag-graph
|
|
65
|
+
* @fires node-select - A node was clicked or activated with the keyboard; `detail` is `{ id }`.
|
|
66
|
+
* @fires direction-change - The toolbar's direction control flipped `direction`; `detail` is `{ direction }`.
|
|
67
|
+
* @slot empty - Shown when there are no nodes.
|
|
68
|
+
*/
|
|
69
|
+
export declare class DagGraph extends LitElement {
|
|
70
|
+
/** Nodes to draw. */
|
|
71
|
+
nodes: DagNode[];
|
|
72
|
+
/** Directed edges between `nodes`; edges with an unknown endpoint or to the node itself are ignored. */
|
|
73
|
+
edges: DagEdge[];
|
|
74
|
+
/** Presentation per node `kind`: legend label, color, icon, and border style. */
|
|
75
|
+
kinds: Record<string, DagNodeKind>;
|
|
76
|
+
/**
|
|
77
|
+
* Id of the selected node. Selecting a node updates it; when it changes to a node outside the visible area,
|
|
78
|
+
* the view follows.
|
|
79
|
+
*/
|
|
80
|
+
selected: string | null;
|
|
81
|
+
/** Layer direction: `LR` (left to right) or `TB` (top to bottom). */
|
|
82
|
+
direction: DagDirection;
|
|
83
|
+
/** Accessible name of the graph; the node and edge counts are appended. */
|
|
84
|
+
label: string;
|
|
85
|
+
/** Shows a legend of `kinds` below the graph. */
|
|
86
|
+
legend: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Space-separated toolbar controls to show: any of `zoom`, `fit`, `center`, and `direction`, in that
|
|
89
|
+
* order. An empty value hides the toolbar.
|
|
90
|
+
*/
|
|
91
|
+
controls: string;
|
|
92
|
+
/** Presents a static picture: always fitted, with panning, zooming, and the toolbar turned off. */
|
|
93
|
+
isStatic: boolean;
|
|
94
|
+
private _view;
|
|
95
|
+
private _hovered;
|
|
96
|
+
private _panning;
|
|
97
|
+
private _svg;
|
|
98
|
+
private _layout;
|
|
99
|
+
private _positions;
|
|
100
|
+
private _size;
|
|
101
|
+
private _viewReady;
|
|
102
|
+
private _lastSelected;
|
|
103
|
+
private _lastDirection;
|
|
104
|
+
private _measure;
|
|
105
|
+
private _measureFont;
|
|
106
|
+
private _resizeObserver;
|
|
107
|
+
private _drag;
|
|
108
|
+
private _suppressClick;
|
|
109
|
+
static styles: import("lit").CSSResult[];
|
|
110
|
+
connectedCallback(): void;
|
|
111
|
+
disconnectedCallback(): void;
|
|
112
|
+
protected firstUpdated(): void;
|
|
113
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
114
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
115
|
+
/** Fits the whole graph into view, never enlarging it beyond 100%. */
|
|
116
|
+
fit(): void;
|
|
117
|
+
/** Centers the view on a node (the selected one by default) at 100% zoom. */
|
|
118
|
+
center(id?: string | null): void;
|
|
119
|
+
/** Zooms by `factor` (e.g. `1.25` or `0.8`) around the center of the view. */
|
|
120
|
+
zoomBy(factor: number): void;
|
|
121
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
122
|
+
/** The enabled `controls`, in their fixed order; none in static mode or without nodes. */
|
|
123
|
+
private get _controls();
|
|
124
|
+
private _renderToolbar;
|
|
125
|
+
private _toggleDirection;
|
|
126
|
+
private _renderEdges;
|
|
127
|
+
private _renderNode;
|
|
128
|
+
private _renderLegend;
|
|
129
|
+
private _edgeKey;
|
|
130
|
+
private _layoutChanged;
|
|
131
|
+
/** Lays the graph out again, keeping the selected node where it was on screen. */
|
|
132
|
+
private _relayout;
|
|
133
|
+
private _initView;
|
|
134
|
+
/**
|
|
135
|
+
* Shows the whole graph when it fits at a readable zoom (always, when static); otherwise centers the selected
|
|
136
|
+
* node at 100%.
|
|
137
|
+
*/
|
|
138
|
+
private _frame;
|
|
139
|
+
/** Brings the selected node into view if it is outside the visible area. */
|
|
140
|
+
private _revealSelected;
|
|
141
|
+
/** Measures labels with the host's actual font, so themes with other fonts still size cards correctly. */
|
|
142
|
+
private _updateMeasure;
|
|
143
|
+
private _resize;
|
|
144
|
+
private _clamp;
|
|
145
|
+
private _centerOn;
|
|
146
|
+
private _zoomAround;
|
|
147
|
+
private _activate;
|
|
148
|
+
private _onNodeKey;
|
|
149
|
+
private _onPointerDown;
|
|
150
|
+
private _onPointerMove;
|
|
151
|
+
private _onPointerUp;
|
|
152
|
+
/** Pinch gestures and Ctrl/⌘ + wheel zoom; a plain wheel is left to the page so it can scroll. */
|
|
153
|
+
private _onWheel;
|
|
154
|
+
private _onKeyDown;
|
|
155
|
+
}
|
|
156
|
+
declare global {
|
|
157
|
+
interface HTMLElementTagNameMap {
|
|
158
|
+
"dag-graph": DagGraph;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=dag-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-graph.d.ts","sourceRoot":"","sources":["../src/dag-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA2B,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAYvG,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAML,KAAK,YAAY,EAKlB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,iCAAiC;AACjC,MAAM,WAAW,OAAO;IACtB,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