@crewlethq/ui 0.121.0 → 0.122.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/README.md +1 -1
- package/dist/GraphCanvas/GraphCanvas.d.ts +187 -0
- package/dist/GraphCanvas/index.d.ts +9 -0
- package/dist/GraphCanvas/index.js +21 -0
- package/dist/GraphCanvas/layout.d.ts +201 -0
- package/dist/GraphCanvas/reach.d.ts +27 -0
- package/dist/GraphCanvas/walk.d.ts +20 -0
- package/dist/GraphCanvas-RSBMO2AF.css +388 -0
- package/dist/ObjectHeader/ObjectHeader.d.ts +17 -2
- package/dist/ObjectHeader/index.d.ts +2 -2
- package/dist/ObjectHeader/index.js +1 -1
- package/dist/{ObjectHeader-5RK5YAUK.css → ObjectHeader-BH7OBEAL.css} +12 -0
- package/dist/OrgTable/index.js +2 -2
- package/dist/PropertyList/index.js +2 -2
- package/dist/ReadingPane/index.js +1 -1
- package/dist/{ReadingPane-POH66FU7.css → ReadingPane-2VJ4JQ3J.css} +7 -0
- package/dist/RichEditor/index.js +1 -1
- package/dist/SetupWizard/index.js +2 -2
- package/dist/StatusLegend/StatusLegend.d.ts +1 -1
- package/dist/StatusLegend/index.js +1 -1
- package/dist/{StatusLegend-HVMKJQFY.css → StatusLegend-DMSTS2NG.css} +9 -0
- package/dist/{chunk-65AMIQSW.js → chunk-4PEPSGCZ.js} +4 -2
- package/dist/chunk-6KPHU4EB.js +1770 -0
- package/dist/{chunk-5LIWAA7S.js → chunk-CXFMNOPV.js} +15 -6
- package/dist/{chunk-3RKS3DLF.js → chunk-ENYHABQJ.js} +1 -1
- package/dist/{chunk-KZTR3V2P.js → chunk-J44ZIWGH.js} +11 -3
- package/dist/{chunk-75QU5C3I.js → chunk-XZ47PWVD.js} +1 -1
- package/dist/generated/index.d.ts +1 -0
- package/dist/generated/index.js +44 -43
- package/dist/index.js +44 -43
- package/dist/styles.css +422 -3
- package/package.json +3 -3
- package/dist/{Editor-JCAYNXQX.js → Editor-SBHTMAEK.js} +1 -1
- package/dist/{chunk-WLL3PFI3.js → chunk-2DZV4PHK.js} +1 -1
- package/dist/{chunk-S2ZUAI6C.js → chunk-MDD6K5M4.js} +1 -1
- /package/dist/{chunk-33NGH63Z.js → chunk-QV3WVNRA.js} +0 -0
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ import { Button } from '@crewlethq/ui/Button'; // 8 KB of CSS, not 182 KB
|
|
|
43
43
|
| Actions | `Button` and `ButtonLink` (variants `primary`, `secondary`, `outline`, `ghost`, `accent`, `danger`; sizes `small`, `medium`, `large`; shapes `square`, `pill`), `IconButton`, `Menu`, `Link`, `Copyable`, `CopyButton`, `DownloadButton`, `Kbd` |
|
|
44
44
|
| Content and text | `Text` (the eight registers and `inherit`; a line cut by `truncate` or `clamp` shows its whole words on hover), `Prose`, `Statement`, `Document`, `DocumentTitle` and `DocumentTitleField`, the Markdown grammar (`parseMarkdown`, `parseMarkdownSpans`, `markdownInline`, `safeHref` and the line readers, with no React in it), `Highlight`, `InlineCode`, `List` and `ListItem`, `DescriptionList`, `Timeline`, `RelativeTime`, `Note`, `Divider` |
|
|
45
45
|
| Forms | `Input`, `Textarea`, `Label`, `FormField`, `FormRow`, `Checkbox`, `CheckboxGroup`, `ConfirmField`, `Select`, `Tag`, `TagsInput`, `DateTimePicker`, `TimeWindowPicker`, `TimeRangePicker`, `ImageUpload`, `CharacterPicker`, `HuePicker`, `AvatarPicker`, `FactList`, `ChoiceList`, `ChoiceCards`, `MemberPicker` (groups granted whole, with members left out or chosen on their own, and `chosenMembers`), `KeyValueRows` (keys and their values as rows under one column head, with `keyValueRowsLabels`), `ChipField` (chosen items as chips inside the field), `PersonRow` (a person or an agent as one row of a list), `Composer`, `MarkdownEditor`, `RichEditor` (with `preloadRichEditor`, and the round trip `roundTripMarkdown` and `canonicalMarkdown` from `@crewlethq/ui/RichEditorMarkdown`) |
|
|
46
|
-
| Data display | `DataGrid` (with `useDataGridDriving`, `useAnyDataGridDriving` and `countDataGridRows`), `DataTable`, `CopyableCell`, `Table`, the read-only table cells (`TableKeyCell`, `TableNumberCell`, `TableDateCell`, `TableEntityCell`, `TableStatusCell`, `TableTagsCell`, `TableTextCell`, `TableTwoLineCell`), `StatCard`, `Meter`, `SegmentedMeter`, `Stepper`, `PricingCard`, `Avatar`, `AvatarStack`, `EntityChip`, `CodeBlock`, `QrCode`, `ObjectHeader`, `FactLine`, `SetByLine`, `Skeleton`, `Eyebrow`, `StatGroup`, `PinTile`, `IconTile`, `SettingsTable` (with `SettingsTable.Row`), `CatalogTile` |
|
|
46
|
+
| Data display | `DataGrid` (with `useDataGridDriving`, `useAnyDataGridDriving` and `countDataGridRows`), `DataTable`, `CopyableCell`, `Table`, the read-only table cells (`TableKeyCell`, `TableNumberCell`, `TableDateCell`, `TableEntityCell`, `TableStatusCell`, `TableTagsCell`, `TableTextCell`, `TableTwoLineCell`), `StatCard`, `Meter`, `SegmentedMeter`, `Stepper`, `PricingCard`, `Avatar`, `AvatarStack`, `EntityChip`, `CodeBlock`, `QrCode`, `ObjectHeader`, `FactLine`, `SetByLine` (set, seen, observed or confirmed by, with `SET_BY_VERBS`), `GraphCanvas` (a layered map of lanes, groups and edges, with its pure layout `layoutGraph`, the reach `graphReach` and the keyboard walk `graphStep`), `Skeleton`, `Eyebrow`, `StatGroup`, `PinTile`, `IconTile`, `SettingsTable` (with `SettingsTable.Row`), `CatalogTile` |
|
|
47
47
|
| List screens | `DataView`, and its parts on their own: `DataViewToolbar`, `FilterAxisBar`, `FilterAxisChip`, `FilterPill`, plus the filter model (`filterDefsFromColumns`, `applyColumnFilters`, `filterPredicate`, `blankFilterValue`) |
|
|
48
48
|
| Feedback and overlays | `Callout`, `AttentionList` (what needs a person, as rows in one card), `ConflictNote`, `EditingStatus`, `Toaster`, `Modal` (with `variant="sheet"`), `ConfirmModal`, `CommandPalette`, `Tooltip`, `Popover`, `Announcer` |
|
|
49
49
|
| Documents and review | `DiffView` and `DiffSummary` with the line diff they draw (`diffLines`, `diffStat`, `collapseDiff`, `firstChangedLines`, `splitLines`, `MAX_DIFF_LINES`, with no React in it), `DiffList`, `VersionCompare`, `CommentThread` |
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A layered map on a canvas: entries in lanes read left to right, bands of
|
|
3
|
+
* lanes under each other, groups that open and close, and orthogonal edges
|
|
4
|
+
* from each entry to what it relies on.
|
|
5
|
+
*
|
|
6
|
+
* PURE PRESENTATION. Entries, edges, the selection and the trace come in as
|
|
7
|
+
* props and every decision goes out through a callback; nothing is fetched.
|
|
8
|
+
* The layout is `layout.ts` (pure, tested without a DOM), the walk `walk.ts`
|
|
9
|
+
* and the reach `reach.ts`; this component measures, draws and listens.
|
|
10
|
+
*
|
|
11
|
+
* IT STAYS LIGHT AT THOUSANDS OF ENTRIES. Every card is one size, so nothing
|
|
12
|
+
* is measured per card; only the cards near the view are mounted; edges are a
|
|
13
|
+
* few paths rather than one element each; and zoomed out past legibility the
|
|
14
|
+
* cards are drawn as shapes on one layer rather than as elements at all.
|
|
15
|
+
*/
|
|
16
|
+
import { type ReactNode, type Ref } from 'react';
|
|
17
|
+
import { type CanvasGround, type CanvasLabels, type CanvasRect, type CanvasSize, type CanvasView } from '../Canvas/index.js';
|
|
18
|
+
import { type GraphTraceDirection } from './reach.js';
|
|
19
|
+
/** A lane: one column of the map, or several in a band with fewer lanes. */
|
|
20
|
+
export interface GraphLane {
|
|
21
|
+
id: string;
|
|
22
|
+
/** Its name, drawn over it: "Runtime". */
|
|
23
|
+
label: string;
|
|
24
|
+
/** What an empty lane says would fill it. Drawn in the lane, and read when the walk reaches it. */
|
|
25
|
+
empty?: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/** A band of lanes. The first is the map's main row; a later one is drawn under it. */
|
|
28
|
+
export interface GraphBand {
|
|
29
|
+
id: string;
|
|
30
|
+
/** A title drawn over a later band, such as "Around it". */
|
|
31
|
+
label?: string | undefined;
|
|
32
|
+
lanes: readonly GraphLane[];
|
|
33
|
+
}
|
|
34
|
+
/** A group of entries inside one lane, drawn as a box with a header, or closed to one card. */
|
|
35
|
+
export interface GraphGroup {
|
|
36
|
+
id: string;
|
|
37
|
+
lane: string;
|
|
38
|
+
/** Its name: "AWS". */
|
|
39
|
+
label: string;
|
|
40
|
+
/** A mark ahead of the name, such as a vendor's. Decorative: the label is read. */
|
|
41
|
+
lead?: ReactNode;
|
|
42
|
+
}
|
|
43
|
+
/** What needs attention on an entry, as one dot: never colour alone, so the word is read with it. */
|
|
44
|
+
export type GraphAttentionTone = 'danger' | 'warning' | 'info';
|
|
45
|
+
export interface GraphAttention {
|
|
46
|
+
tone: GraphAttentionTone;
|
|
47
|
+
/** The word a screen reader hears, such as "Alerting". */
|
|
48
|
+
label: string;
|
|
49
|
+
}
|
|
50
|
+
export interface GraphNode {
|
|
51
|
+
id: string;
|
|
52
|
+
lane: string;
|
|
53
|
+
group?: string | undefined;
|
|
54
|
+
/** The first line: "orders-db". */
|
|
55
|
+
name: string;
|
|
56
|
+
/** The second line, in the quiet ink: "postgres 16 · eu-west-1". */
|
|
57
|
+
caption?: string | undefined;
|
|
58
|
+
/** What it is, read after the name: "Database". */
|
|
59
|
+
kind?: string | undefined;
|
|
60
|
+
/** The kind's glyph, drawn on a tile at the card's start. */
|
|
61
|
+
glyph?: ReactNode;
|
|
62
|
+
/** A dot on the card's corner, only when something needs a person. */
|
|
63
|
+
attention?: GraphAttention | undefined;
|
|
64
|
+
/** Not confirmed by anyone the map trusts: drawn with a dashed edge. */
|
|
65
|
+
unconfirmed?: boolean | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** An edge from the entry that relies to the entry relied on. */
|
|
68
|
+
export interface GraphEdge {
|
|
69
|
+
id: string;
|
|
70
|
+
from: string;
|
|
71
|
+
to: string;
|
|
72
|
+
/** The relation, as words a reader hears in a card's description: "runs on". */
|
|
73
|
+
label?: string | undefined;
|
|
74
|
+
/** Drawn while nothing is selected. Off for a relation that would cross the whole map (an owning account). */
|
|
75
|
+
atRest?: boolean | undefined;
|
|
76
|
+
}
|
|
77
|
+
/** What a trace lights from the selected entry: which way, and how many hops. */
|
|
78
|
+
export interface GraphTrace {
|
|
79
|
+
direction: GraphTraceDirection;
|
|
80
|
+
/** At least one; `Infinity` for no limit. */
|
|
81
|
+
depth: number;
|
|
82
|
+
}
|
|
83
|
+
/** A relation in a card's spoken description. */
|
|
84
|
+
export interface GraphRelationText {
|
|
85
|
+
relation: string | undefined;
|
|
86
|
+
name: string;
|
|
87
|
+
}
|
|
88
|
+
/** Every string the map says on its own, for another language. */
|
|
89
|
+
export interface GraphCanvasLabels extends CanvasLabels {
|
|
90
|
+
/** A lane's name with its count: "Runtime, 3 entries". */
|
|
91
|
+
lane: (label: string, count: number) => string;
|
|
92
|
+
/** A count of entries, under a closed group's name and beside an open one's. */
|
|
93
|
+
entries: (count: number) => string;
|
|
94
|
+
/** An open group's header: "AWS, 12 entries, open". */
|
|
95
|
+
openGroup: (label: string, count: number) => string;
|
|
96
|
+
/** A closed group's card: "AWS, 42 entries, closed". */
|
|
97
|
+
closedGroup: (label: string, count: number) => string;
|
|
98
|
+
/** An empty lane, before its message: "Runtime, empty". */
|
|
99
|
+
emptyLane: (label: string) => string;
|
|
100
|
+
/** Read after an unconfirmed entry's name. */
|
|
101
|
+
unconfirmed: string;
|
|
102
|
+
/** A card's description: what it relies on and what relies on it. */
|
|
103
|
+
relations: (dependsOn: readonly GraphRelationText[], usedBy: readonly GraphRelationText[]) => string;
|
|
104
|
+
}
|
|
105
|
+
export declare const GRAPH_CANVAS_LABELS: GraphCanvasLabels;
|
|
106
|
+
/**
|
|
107
|
+
* THE ZOOM BELOW WHICH CARDS ARE SHAPES. At half size a 13px name draws at
|
|
108
|
+
* about 6.5px, the least that still reads as words; below it a card's text is
|
|
109
|
+
* texture, so the map draws every card as a shape on one layer instead.
|
|
110
|
+
*/
|
|
111
|
+
export declare const GRAPH_CANVAS_DETAIL_ZOOM = 0.5;
|
|
112
|
+
/**
|
|
113
|
+
* THE ZOOM A MAP TOO LARGE TO READ WHOLE OPENS AT, on its start: a card's
|
|
114
|
+
* 13px name draws at about 10px, and five lanes still fit across a laptop.
|
|
115
|
+
*/
|
|
116
|
+
export declare const GRAPH_CANVAS_OPEN_ZOOM = 0.75;
|
|
117
|
+
/**
|
|
118
|
+
* THE LOWEST ZOOM A FIT TAKES, so the whole map is one press away however
|
|
119
|
+
* large: two thousand entries in five lanes fit at about a twentieth.
|
|
120
|
+
*/
|
|
121
|
+
export declare const GRAPH_CANVAS_FIT_FLOOR = 0.02;
|
|
122
|
+
/** What a screen can ask of a map it holds a ref to. */
|
|
123
|
+
export interface GraphCanvasHandle {
|
|
124
|
+
/** Moves focus to an entry's card, opening its group and bringing it into view. */
|
|
125
|
+
focusNode(id: string): void;
|
|
126
|
+
/** Shows the whole map. */
|
|
127
|
+
fit(): void;
|
|
128
|
+
}
|
|
129
|
+
export interface GraphCanvasProps {
|
|
130
|
+
/** The map's accessible name: "Atlas map". */
|
|
131
|
+
label: string;
|
|
132
|
+
bands: readonly GraphBand[];
|
|
133
|
+
nodes: readonly GraphNode[];
|
|
134
|
+
edges: readonly GraphEdge[];
|
|
135
|
+
groups?: readonly GraphGroup[] | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Groups start closed when the map holds more entries than this, so a large
|
|
138
|
+
* map opens as a summary. Unset, every group starts open.
|
|
139
|
+
*/
|
|
140
|
+
collapseAbove?: number | undefined;
|
|
141
|
+
/** The open groups, when the caller holds them. */
|
|
142
|
+
openGroups?: ReadonlySet<string> | undefined;
|
|
143
|
+
/** Called with the open groups whenever one opens or closes. */
|
|
144
|
+
onOpenGroupsChange?: ((open: ReadonlySet<string>) => void) | undefined;
|
|
145
|
+
selectedId?: string | null | undefined;
|
|
146
|
+
/** A press or Enter on a card selects it; Escape clears with `null`. */
|
|
147
|
+
onSelect?: ((id: string | null) => void) | undefined;
|
|
148
|
+
/** Lights what the selection reaches; unset, the selection lights its neighbours. */
|
|
149
|
+
trace?: GraphTrace | null | undefined;
|
|
150
|
+
/** A card pushed back, such as one a legend filter leaves out. */
|
|
151
|
+
cardDimmed?: ((id: string) => boolean) | undefined;
|
|
152
|
+
/** Drawn over the canvas without the transform. */
|
|
153
|
+
overlay?: ReactNode;
|
|
154
|
+
controlsPlacement?: 'top-right' | 'bottom-right' | undefined;
|
|
155
|
+
controlsExtra?: ReactNode;
|
|
156
|
+
controlsBelow?: ReactNode;
|
|
157
|
+
/** A bar in the corner opposite the zoom bar, such as the trace switch. */
|
|
158
|
+
controlsStart?: ReactNode;
|
|
159
|
+
/** A bar across from the zoom bar, such as a status legend. */
|
|
160
|
+
overlayEnd?: ReactNode;
|
|
161
|
+
hint?: ReactNode;
|
|
162
|
+
ground?: CanvasGround | undefined;
|
|
163
|
+
labels?: Partial<GraphCanvasLabels> | undefined;
|
|
164
|
+
/** The lowest zoom a fit may take: [GRAPH_CANVAS_FIT_FLOOR] unless named. */
|
|
165
|
+
minZoom?: number | undefined;
|
|
166
|
+
/** Fits the whole map again whenever this changes. */
|
|
167
|
+
fitKey?: string | number | undefined;
|
|
168
|
+
/** The view to open on instead of the opening fit. */
|
|
169
|
+
initialView?: CanvasView | undefined;
|
|
170
|
+
onViewChange?: ((view: CanvasView, viewport: CanvasSize) => void) | undefined;
|
|
171
|
+
ref?: Ref<GraphCanvasHandle> | undefined;
|
|
172
|
+
className?: string | undefined;
|
|
173
|
+
}
|
|
174
|
+
/** The part of the world that is mounted: what is near the view, with room to pan before it moves. */
|
|
175
|
+
export interface GraphWindow {
|
|
176
|
+
rect: CanvasRect;
|
|
177
|
+
/** Whether cards are drawn as cards, or as shapes for a zoom too far out to read. */
|
|
178
|
+
detail: boolean;
|
|
179
|
+
}
|
|
180
|
+
export declare function GraphCanvas({ label, bands, nodes, edges, groups, collapseAbove, openGroups, onOpenGroupsChange, selectedId, onSelect, trace, cardDimmed, overlay, controlsPlacement, controlsExtra, controlsBelow, controlsStart, overlayEnd, hint, ground, labels, minZoom, fitKey, initialView, onViewChange, ref, className, }: GraphCanvasProps): import("react").JSX.Element;
|
|
181
|
+
/**
|
|
182
|
+
* THE WINDOW MOVES IN STEPS. What is mounted is the view with half a screen
|
|
183
|
+
* of room on every side, and it is replaced only when the view leaves it or
|
|
184
|
+
* shrinks far inside it, so a pan re-renders the map every half screen rather
|
|
185
|
+
* than every frame.
|
|
186
|
+
*/
|
|
187
|
+
export declare function graphWindow(was: GraphWindow | null, view: CanvasView, viewport: CanvasSize): GraphWindow;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './GraphCanvas.css';
|
|
2
|
+
export { GRAPH_CANVAS_DETAIL_ZOOM, GRAPH_CANVAS_FIT_FLOOR, GRAPH_CANVAS_LABELS, GRAPH_CANVAS_OPEN_ZOOM, GraphCanvas, graphWindow, } from './GraphCanvas.js';
|
|
3
|
+
export type { GraphAttention, GraphAttentionTone, GraphBand, GraphCanvasHandle, GraphCanvasLabels, GraphCanvasProps, GraphEdge, GraphGroup, GraphLane, GraphNode, GraphRelationText, GraphTrace, GraphWindow, } from './GraphCanvas.js';
|
|
4
|
+
export { GRAPH_ORDER_SWEEPS, graphItemKey, layoutGraph, routeGraphEdges } from './layout.js';
|
|
5
|
+
export type { GraphBandPlaced, GraphGrid, GraphGroupPlaced, GraphItem, GraphItemKind, GraphLanePlaced, GraphLayout, GraphLayoutBand, GraphLayoutEdge, GraphLayoutGroup, GraphLayoutInput, GraphLayoutNode, GraphMetrics, GraphRoute, GraphStreet, } from './layout.js';
|
|
6
|
+
export { graphNeighbourhood, graphReach } from './reach.js';
|
|
7
|
+
export type { GraphReach, GraphTraceDirection } from './reach.js';
|
|
8
|
+
export { graphStep } from './walk.js';
|
|
9
|
+
export type { GraphStepKey } from './walk.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { GRAPH_CANVAS_DETAIL_ZOOM, GRAPH_CANVAS_FIT_FLOOR, GRAPH_CANVAS_LABELS, GRAPH_CANVAS_OPEN_ZOOM, GRAPH_ORDER_SWEEPS, GraphCanvas, graphItemKey, graphNeighbourhood, graphReach, graphStep, graphWindow, layoutGraph, routeGraphEdges } from '../chunk-6KPHU4EB.js';
|
|
2
|
+
import '../chunk-MY374UUD.js';
|
|
3
|
+
import '../chunk-3LI4TRUR.js';
|
|
4
|
+
import '../chunk-GKHZSNIV.js';
|
|
5
|
+
import '../chunk-X4HBZSXA.js';
|
|
6
|
+
import '../chunk-XLMURU75.js';
|
|
7
|
+
import '../chunk-WSIJDWUG.js';
|
|
8
|
+
import '../chunk-QRE6JCHS.js';
|
|
9
|
+
import '../chunk-VBBLHS2Y.js';
|
|
10
|
+
import '../chunk-M2M6ZD7P.js';
|
|
11
|
+
import '../chunk-XSPCITPN.js';
|
|
12
|
+
import '../chunk-X5YI6E5X.js';
|
|
13
|
+
import '../chunk-TDFLCUBE.js';
|
|
14
|
+
import '../chunk-HXVMXH6U.js';
|
|
15
|
+
import '../chunk-L72URIHR.js';
|
|
16
|
+
import '../chunk-HTS5RJ7S.js';
|
|
17
|
+
import '../chunk-FIX72ZEC.js';
|
|
18
|
+
import '../chunk-EDPMHSLZ.js';
|
|
19
|
+
import '../chunk-4ITETIGZ.js';
|
|
20
|
+
import '../chunk-RRRK2KB6.js';
|
|
21
|
+
import '../chunk-ODEQTPFM.js';
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The layout of a layered map, as pure functions: lanes read left to right,
|
|
3
|
+
* bands stacked under each other, groups inside a lane, and orthogonal edges.
|
|
4
|
+
*
|
|
5
|
+
* ONE ROW GRID PER BAND. Every card is the same size and stands in a cell of
|
|
6
|
+
* its band's grid, a group's header takes a row of its own, and an empty lane
|
|
7
|
+
* keeps the rows its message needs. Because every lane of a band shares the
|
|
8
|
+
* rows, the gaps between rows are free of cards in every lane at once, so an
|
|
9
|
+
* edge that crosses a lane runs along a gap and never through a card.
|
|
10
|
+
*
|
|
11
|
+
* LANES ARE INPUT. Nothing here assigns ranks: a cycle is an edge drawn back
|
|
12
|
+
* across a lane, and the order inside a lane is a fixed number of barycentric
|
|
13
|
+
* sweeps, ties broken by the caller's order, so the same input always gives
|
|
14
|
+
* the same picture.
|
|
15
|
+
*/
|
|
16
|
+
import type { CanvasPoint, CanvasRect } from '../Canvas/geometry.js';
|
|
17
|
+
/** A band of lanes, top to bottom; its lanes read left to right. */
|
|
18
|
+
export interface GraphLayoutBand {
|
|
19
|
+
id: string;
|
|
20
|
+
/** Whether the band draws a title above its lane headers. */
|
|
21
|
+
titled: boolean;
|
|
22
|
+
/** The ids of its lanes, in reading order. */
|
|
23
|
+
lanes: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
export interface GraphLayoutNode {
|
|
26
|
+
id: string;
|
|
27
|
+
lane: string;
|
|
28
|
+
group?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface GraphLayoutGroup {
|
|
31
|
+
id: string;
|
|
32
|
+
lane: string;
|
|
33
|
+
}
|
|
34
|
+
/** An edge from the entry that relies to the entry relied on. */
|
|
35
|
+
export interface GraphLayoutEdge {
|
|
36
|
+
id: string;
|
|
37
|
+
from: string;
|
|
38
|
+
to: string;
|
|
39
|
+
}
|
|
40
|
+
/** The sizes the layout is drawn at, measured from the stylesheet. */
|
|
41
|
+
export interface GraphMetrics {
|
|
42
|
+
cardWidth: number;
|
|
43
|
+
cardHeight: number;
|
|
44
|
+
/** The channel between two columns, where vertical runs of edges go. */
|
|
45
|
+
gutter: number;
|
|
46
|
+
/** The gap between two rows, where horizontal runs of edges go. */
|
|
47
|
+
rowGap: number;
|
|
48
|
+
/** The room a lane's header takes above its first row. */
|
|
49
|
+
laneHead: number;
|
|
50
|
+
/** The room a titled band's title takes above its lane headers. */
|
|
51
|
+
bandHead: number;
|
|
52
|
+
/** The space between two bands. */
|
|
53
|
+
bandGap: number;
|
|
54
|
+
/** How far a lane's panel reaches past its cards. */
|
|
55
|
+
lanePad: number;
|
|
56
|
+
/** The space around the whole map. */
|
|
57
|
+
margin: number;
|
|
58
|
+
}
|
|
59
|
+
export interface GraphLayoutInput {
|
|
60
|
+
bands: readonly GraphLayoutBand[];
|
|
61
|
+
nodes: readonly GraphLayoutNode[];
|
|
62
|
+
groups?: readonly GraphLayoutGroup[] | undefined;
|
|
63
|
+
/** Whether a group is drawn open. A closed group is one summary card. */
|
|
64
|
+
open: (groupId: string) => boolean;
|
|
65
|
+
/** The edges drawn at rest, which also decide the order inside a lane. */
|
|
66
|
+
edges: readonly GraphLayoutEdge[];
|
|
67
|
+
/** The height an empty lane's message takes, by lane id. Unlisted lanes keep one row. */
|
|
68
|
+
emptyHeights?: ReadonlyMap<string, number> | undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* What stands in a cell: an entry, a closed group's summary, an open group's
|
|
72
|
+
* header row, or the message of an empty lane.
|
|
73
|
+
*/
|
|
74
|
+
export type GraphItemKind = 'node' | 'summary' | 'head' | 'empty';
|
|
75
|
+
export interface GraphItem extends CanvasRect {
|
|
76
|
+
/** Unique across kinds: see [graphItemKey]. */
|
|
77
|
+
key: string;
|
|
78
|
+
kind: GraphItemKind;
|
|
79
|
+
/** The entry's id, the group's id, or the lane's id for an empty lane. */
|
|
80
|
+
id: string;
|
|
81
|
+
lane: string;
|
|
82
|
+
band: number;
|
|
83
|
+
/** The first column and row it covers, in its band's grid. */
|
|
84
|
+
col: number;
|
|
85
|
+
row: number;
|
|
86
|
+
cols: number;
|
|
87
|
+
rows: number;
|
|
88
|
+
}
|
|
89
|
+
export interface GraphLanePlaced {
|
|
90
|
+
id: string;
|
|
91
|
+
band: number;
|
|
92
|
+
/** The first column, and how many it spans. */
|
|
93
|
+
col: number;
|
|
94
|
+
span: number;
|
|
95
|
+
rows: number;
|
|
96
|
+
/** Its panel: the header and every row, with its padding. */
|
|
97
|
+
panel: CanvasRect;
|
|
98
|
+
/** Its header's box, above the first row. */
|
|
99
|
+
head: CanvasRect;
|
|
100
|
+
/** Its items, in reading order, which is the order the keyboard walks. */
|
|
101
|
+
items: string[];
|
|
102
|
+
/** How many entries it holds, closed groups' members included. */
|
|
103
|
+
count: number;
|
|
104
|
+
}
|
|
105
|
+
export interface GraphBandPlaced {
|
|
106
|
+
id: string;
|
|
107
|
+
index: number;
|
|
108
|
+
/** Its title's box, for a titled band. */
|
|
109
|
+
title: CanvasRect | null;
|
|
110
|
+
rowsTop: number;
|
|
111
|
+
rows: number;
|
|
112
|
+
}
|
|
113
|
+
export interface GraphGroupPlaced {
|
|
114
|
+
id: string;
|
|
115
|
+
lane: string;
|
|
116
|
+
open: boolean;
|
|
117
|
+
/** The box drawn round an open group's header and members; a closed group draws its summary instead. */
|
|
118
|
+
box: CanvasRect | null;
|
|
119
|
+
/** Its members' ids, in drawn order. */
|
|
120
|
+
members: string[];
|
|
121
|
+
}
|
|
122
|
+
/** One drawn edge. Several edges between the same two items are one route. */
|
|
123
|
+
export interface GraphRoute {
|
|
124
|
+
key: string;
|
|
125
|
+
from: string;
|
|
126
|
+
to: string;
|
|
127
|
+
/** The edges it draws. */
|
|
128
|
+
edges: string[];
|
|
129
|
+
points: CanvasPoint[];
|
|
130
|
+
/** The path, ending at the arrowhead's base. */
|
|
131
|
+
d: string;
|
|
132
|
+
/** The arrowhead, as a closed path. */
|
|
133
|
+
arrow: string;
|
|
134
|
+
/** The box round every point, for drawing only the routes near the view. */
|
|
135
|
+
box: CanvasRect;
|
|
136
|
+
}
|
|
137
|
+
export interface GraphLayout {
|
|
138
|
+
bounds: CanvasRect;
|
|
139
|
+
metrics: GraphMetrics;
|
|
140
|
+
columns: number;
|
|
141
|
+
bands: GraphBandPlaced[];
|
|
142
|
+
lanes: GraphLanePlaced[];
|
|
143
|
+
laneById: ReadonlyMap<string, GraphLanePlaced>;
|
|
144
|
+
items: GraphItem[];
|
|
145
|
+
itemByKey: ReadonlyMap<string, GraphItem>;
|
|
146
|
+
/** The item an entry is drawn as: its own card, or its closed group's summary. */
|
|
147
|
+
itemOfNode: ReadonlyMap<string, string>;
|
|
148
|
+
groups: GraphGroupPlaced[];
|
|
149
|
+
groupById: ReadonlyMap<string, GraphGroupPlaced>;
|
|
150
|
+
routes: GraphRoute[];
|
|
151
|
+
/** The route each at-rest edge is drawn by. */
|
|
152
|
+
routeOfEdge: ReadonlyMap<string, string>;
|
|
153
|
+
/** What routing another set of edges needs: see [routeGraphEdges]. */
|
|
154
|
+
grid: GraphGrid;
|
|
155
|
+
}
|
|
156
|
+
/** The streets and cells edges are routed through. */
|
|
157
|
+
export interface GraphGrid {
|
|
158
|
+
/** Each column's left edge. */
|
|
159
|
+
colX: readonly number[];
|
|
160
|
+
/** Each vertical channel's centre: channel `c` is left of column `c`, the last one right of the last column. */
|
|
161
|
+
channelX: readonly number[];
|
|
162
|
+
/** Every horizontal street, top to bottom. */
|
|
163
|
+
streets: readonly GraphStreet[];
|
|
164
|
+
/** Each band's own streets, as indices into `streets`, top to bottom. */
|
|
165
|
+
bandStreets: readonly (readonly number[])[];
|
|
166
|
+
/** The street in the gap above each band after the first, by the band's index. */
|
|
167
|
+
gapStreets: ReadonlyMap<number, number>;
|
|
168
|
+
/** Whether a cell holds anything, by band: `occupied[band][row * columns + col]`. */
|
|
169
|
+
occupied: readonly Uint8Array[];
|
|
170
|
+
bandRows: readonly number[];
|
|
171
|
+
bandRowsTop: readonly number[];
|
|
172
|
+
}
|
|
173
|
+
export interface GraphStreet {
|
|
174
|
+
y: number;
|
|
175
|
+
/** The band whose rows it runs between, or -1 for the gap between two bands. */
|
|
176
|
+
band: number;
|
|
177
|
+
/** For the gap between two bands, the lower band's index; -1 otherwise. */
|
|
178
|
+
gap: number;
|
|
179
|
+
/** Whether a group box's edge runs beside it in a column, by column: a run there would double that edge. */
|
|
180
|
+
dirty: Uint8Array;
|
|
181
|
+
/** Whether it runs through an empty lane's message in a column, by column. */
|
|
182
|
+
blocked: Uint8Array;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* HOW MANY ORDERING SWEEPS: four each way. On the suite's fixtures the
|
|
186
|
+
* crossings stopped falling at eight (twelve drew the same maps), and each
|
|
187
|
+
* sweep is linear in the entries and edges.
|
|
188
|
+
*/
|
|
189
|
+
export declare const GRAPH_ORDER_SWEEPS = 8;
|
|
190
|
+
/** An item's key, unique across kinds even when an entry, a group and a lane share an id. */
|
|
191
|
+
export declare function graphItemKey(kind: GraphItemKind, id: string): string;
|
|
192
|
+
/**
|
|
193
|
+
* Lays out a map. Throws on input that cannot be drawn: an entry or a group in
|
|
194
|
+
* a lane no band lists, an entry in a group of another lane, or a repeated id.
|
|
195
|
+
*/
|
|
196
|
+
export declare function layoutGraph(input: GraphLayoutInput, metrics: GraphMetrics): GraphLayout;
|
|
197
|
+
/**
|
|
198
|
+
* Routes a set of edges over a layout that is already placed, such as the
|
|
199
|
+
* edges a selection reveals: each pair of drawn items once, in its own tracks.
|
|
200
|
+
*/
|
|
201
|
+
export declare function routeGraphEdges(layout: GraphLayout, edges: readonly GraphLayoutEdge[]): GraphRoute[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a selected entry reaches along the edges, as a pure function the map
|
|
3
|
+
* and its caller share, so the count a screen says ("14 entries depend on
|
|
4
|
+
* orders-db") is the set the map lights.
|
|
5
|
+
*/
|
|
6
|
+
import type { GraphLayoutEdge } from './layout.js';
|
|
7
|
+
/**
|
|
8
|
+
* Which way a trace walks. Edges point from the entry that relies to the one
|
|
9
|
+
* relied on, so `up` is what depends on the start, `down` is what the start
|
|
10
|
+
* depends on, and `both` is the two together.
|
|
11
|
+
*/
|
|
12
|
+
export type GraphTraceDirection = 'up' | 'down' | 'both';
|
|
13
|
+
export interface GraphReach {
|
|
14
|
+
/** Every entry reached, the start included, with its distance in hops. */
|
|
15
|
+
nodes: ReadonlyMap<string, number>;
|
|
16
|
+
/** The edges the walk took. */
|
|
17
|
+
edges: ReadonlySet<string>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Walks from `from` along `edges` in `direction`, at most `depth` hops
|
|
21
|
+
* (`Infinity` for no limit). Breadth first, so each entry's distance is its
|
|
22
|
+
* shortest; an edge is taken when its far end is within the limit, which
|
|
23
|
+
* includes an edge closing a cycle back onto an entry already reached.
|
|
24
|
+
*/
|
|
25
|
+
export declare function graphReach(edges: readonly GraphLayoutEdge[], from: string, direction: GraphTraceDirection, depth: number): GraphReach;
|
|
26
|
+
/** The entries one edge away from `id`, either way, and the edges that touch it. */
|
|
27
|
+
export declare function graphNeighbourhood(edges: readonly GraphLayoutEdge[], id: string): GraphReach;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keyboard walk over a laid out map, as a pure function of the layout.
|
|
3
|
+
*
|
|
4
|
+
* Up and Down move through a lane in reading order and on into the band above
|
|
5
|
+
* or below; Left and Right move to the item nearest in height in the lane
|
|
6
|
+
* beside; Home and End go to a lane's ends, and with Control or Command to the
|
|
7
|
+
* map's. An empty lane is a stop too, so its message is read.
|
|
8
|
+
*/
|
|
9
|
+
import type { GraphLayout } from './layout.js';
|
|
10
|
+
export interface GraphStepKey {
|
|
11
|
+
key: string;
|
|
12
|
+
ctrlKey?: boolean;
|
|
13
|
+
metaKey?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The item a key moves to from `from`, `null` for a key the walk owns that
|
|
17
|
+
* goes nowhere from here (so it is still swallowed), and `undefined` for a key
|
|
18
|
+
* that is not the walk's.
|
|
19
|
+
*/
|
|
20
|
+
export declare function graphStep(layout: GraphLayout, from: string, event: GraphStepKey): string | null | undefined;
|