@pipelex/mthds-ui 0.38.0 → 0.40.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 +4 -2
- package/dist/chunk-7JZBXBZS.js +258 -0
- package/dist/chunk-7JZBXBZS.js.map +1 -0
- package/dist/{chunk-AGFLCOWW.js → chunk-HPARBH6K.js} +14 -197
- package/dist/chunk-HPARBH6K.js.map +1 -0
- package/dist/chunk-N2F62MW7.js +55 -0
- package/dist/chunk-N2F62MW7.js.map +1 -0
- package/dist/chunk-P6IGZVWE.js +155 -0
- package/dist/chunk-P6IGZVWE.js.map +1 -0
- package/dist/chunk-RU3CIXFC.js +1251 -0
- package/dist/chunk-RU3CIXFC.js.map +1 -0
- package/dist/form/brand/index.js.map +1 -1
- package/dist/form/react/index.d.ts +36 -3
- package/dist/form/react/index.js +45 -14
- package/dist/form/react/index.js.map +1 -1
- package/dist/graph/index.d.ts +19 -3
- package/dist/graph/index.js +20 -12
- package/dist/graph/react/index.d.ts +13 -13
- package/dist/graph/react/index.js +387 -560
- package/dist/graph/react/index.js.map +1 -1
- package/dist/graph/react/viewer/GraphToolbar.css +2 -107
- package/dist/graph/react/viewer/StyleMenu.css +109 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -12
- package/dist/registryJoin-C6Wfkik-.d.ts +441 -0
- package/dist/standalone/graph-standalone.html +183 -178
- package/dist/standalone/graph-viewer.css +75 -70
- package/dist/standalone/graph-viewer.js +108 -108
- package/dist/static-graph/index.d.ts +1 -1
- package/dist/timeline/index.d.ts +240 -77
- package/dist/timeline/index.js +61 -3
- package/dist/timeline/react/RunTimeline.css +48 -0
- package/dist/timeline/react/index.d.ts +46 -4
- package/dist/timeline/react/index.js +774 -105
- package/dist/timeline/react/index.js.map +1 -1
- package/dist/timeline/react/styles/simple/SimpleProgress.css +354 -0
- package/dist/{types-DsrzH6gM.d.ts → types-DLAnYNoi.d.ts} +1 -1
- package/package.json +5 -3
- package/dist/chunk-AGFLCOWW.js.map +0 -1
- package/dist/chunk-ILZJIORT.js +0 -54
- package/dist/chunk-ILZJIORT.js.map +0 -1
- package/dist/chunk-JJG2TO7P.js +0 -473
- package/dist/chunk-JJG2TO7P.js.map +0 -1
- package/dist/progressSnapshot-VZ4PLul9.d.ts +0 -191
package/README.md
CHANGED
|
@@ -311,7 +311,7 @@ See `graphConfig.ts` for the full default palette.
|
|
|
311
311
|
| `@pipelex/mthds-ui/form/brand` | The kernel's brand entry: seed colours into readable colour roles |
|
|
312
312
|
| `@pipelex/mthds-ui/form/react` | `RunPanel` — a pipe's input form — and the kernel's controls |
|
|
313
313
|
| `@pipelex/mthds-ui/timeline` | A run's progress snapshot: types, path grammar, rows and time axis |
|
|
314
|
-
| `@pipelex/mthds-ui/timeline/react` | `RunTimeline` — a
|
|
314
|
+
| `@pipelex/mthds-ui/timeline/react` | `RunTimeline` — a run's progress as growing bars or a checklist |
|
|
315
315
|
| `@pipelex/mthds-ui/shiki` | MTHDS syntax highlighting with shiki |
|
|
316
316
|
| `@pipelex/mthds-ui/tailwind.css` | Where the kernel's classes are, for a Tailwind 4 host |
|
|
317
317
|
| `@pipelex/mthds-ui/form-kernel.css` | The kernel's prebuilt stylesheet, for a host without Tailwind |
|
|
@@ -396,7 +396,7 @@ Tailwind 3 hosts and Tailwind 4 hosts that configure a prefix are not supported:
|
|
|
396
396
|
|
|
397
397
|
Either way, the shadcn token values are yours to supply, and each must be a **complete colour** — `hsl(240 10% 3.9%)`, `#0a0711`, `oklch(…)` — never a bare HSL triplet. Since kernel `0.8.0` the sheet emits `background-color: var(--background)` rather than `hsl(var(--background))`, so a triplet computes to something that is not a colour and the browser discards the declaration instead of overriding with it: green build, token inspectable, style silently absent.
|
|
398
398
|
|
|
399
|
-
To brand the controls with a team's own colours, `@pipelex/mthds-ui/form/brand` derives `--primary`
|
|
399
|
+
To brand the controls with a team's own colours, `@pipelex/mthds-ui/form/brand` derives colour roles from up to three colours a person picked, every text colour readable on the theme's page: a host writes `action` onto `--primary`, `accentInk` onto the optional `--link` (the accent as text) and onto `--ring` (every focus the controls draw), and `accentFill` onto the optional `--selected` (the pale fill of a selected pill, tag or step). A role the team left unset comes back absent, so the host writes no token for it and keeps its own, and a page that defines neither `--link` nor `--selected` falls back to `--primary` for both.
|
|
400
400
|
|
|
401
401
|
Full contract, why this package stopped loading the kernel's stylesheet itself, the `.dark` bridge, the `mthds-run-panel` token hook and the brand tokens: [docs/run-form-panel.md](./docs/run-form-panel.md).
|
|
402
402
|
|
|
@@ -412,6 +412,8 @@ import { RunTimeline } from "@pipelex/mthds-ui/timeline/react";
|
|
|
412
412
|
<RunTimeline snapshot={snapshot} theme="dark" />;
|
|
413
413
|
```
|
|
414
414
|
|
|
415
|
+
`timelineStyle="simple"` draws the same run as a checklist of its steps in the method's own words, titled from the method's pipe registry the host passes as `pipeRegistry`, with each batch as one line of counts, for a reader who did not write the method; `styleMenu` lets the reader switch. See [docs/timeline-styles.md](./docs/timeline-styles.md).
|
|
416
|
+
|
|
415
417
|
The entry imports its own stylesheet, and the timeline themes itself with the same tokens as `GraphViewer`. The snapshot's types and the projection the component draws are in the React-free `@pipelex/mthds-ui/timeline`. Props, the freshness rule, what each row and bar shows, and the stories: [docs/run-timeline.md](./docs/run-timeline.md).
|
|
416
418
|
|
|
417
419
|
## Shiki integration
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GRAPH_STYLES
|
|
3
|
+
} from "./chunk-N2F62MW7.js";
|
|
4
|
+
import {
|
|
5
|
+
GRAPH_STYLE,
|
|
6
|
+
GRAPH_THEME
|
|
7
|
+
} from "./chunk-4KLE62AN.js";
|
|
8
|
+
import {
|
|
9
|
+
__spreadProps,
|
|
10
|
+
__spreadValues
|
|
11
|
+
} from "./chunk-2NMEKWO5.js";
|
|
12
|
+
|
|
13
|
+
// src/graph/react/viewer/useSystemTheme.ts
|
|
14
|
+
import React from "react";
|
|
15
|
+
var PREFERS_DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
16
|
+
function prefersDarkToTheme(prefersDark) {
|
|
17
|
+
return prefersDark ? GRAPH_THEME.DARK : GRAPH_THEME.LIGHT;
|
|
18
|
+
}
|
|
19
|
+
function detectSystemTheme() {
|
|
20
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
21
|
+
return GRAPH_THEME.DARK;
|
|
22
|
+
}
|
|
23
|
+
return prefersDarkToTheme(window.matchMedia(PREFERS_DARK_QUERY).matches);
|
|
24
|
+
}
|
|
25
|
+
function subscribeToSystemTheme(onChange) {
|
|
26
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
27
|
+
return () => {
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const mql = window.matchMedia(PREFERS_DARK_QUERY);
|
|
31
|
+
if (typeof mql.addEventListener === "function") {
|
|
32
|
+
mql.addEventListener("change", onChange);
|
|
33
|
+
return () => mql.removeEventListener("change", onChange);
|
|
34
|
+
}
|
|
35
|
+
mql.addListener(onChange);
|
|
36
|
+
return () => mql.removeListener(onChange);
|
|
37
|
+
}
|
|
38
|
+
function systemThemeStore(injected) {
|
|
39
|
+
if (injected !== void 0) {
|
|
40
|
+
return {
|
|
41
|
+
subscribe: () => () => {
|
|
42
|
+
},
|
|
43
|
+
getSnapshot: () => injected,
|
|
44
|
+
getServerSnapshot: () => injected
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
subscribe: subscribeToSystemTheme,
|
|
49
|
+
getSnapshot: detectSystemTheme,
|
|
50
|
+
getServerSnapshot: () => GRAPH_THEME.DARK
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function useSystemTheme(injected) {
|
|
54
|
+
const store = React.useMemo(() => systemThemeStore(injected), [injected]);
|
|
55
|
+
return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/graph/react/viewer/usePopoverDismiss.ts
|
|
59
|
+
import React2 from "react";
|
|
60
|
+
function usePopoverDismiss(open, wrapperRef, onDismiss) {
|
|
61
|
+
const onDismissRef = React2.useRef(onDismiss);
|
|
62
|
+
onDismissRef.current = onDismiss;
|
|
63
|
+
React2.useEffect(() => {
|
|
64
|
+
if (!open) return;
|
|
65
|
+
const onPointerDown = (event) => {
|
|
66
|
+
const wrapper = wrapperRef.current;
|
|
67
|
+
if (wrapper && event.target instanceof Node && !wrapper.contains(event.target)) {
|
|
68
|
+
onDismissRef.current("outside");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const onKeyDown = (event) => {
|
|
72
|
+
if (event.key === "Escape") onDismissRef.current("escape");
|
|
73
|
+
};
|
|
74
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
75
|
+
document.addEventListener("keydown", onKeyDown);
|
|
76
|
+
return () => {
|
|
77
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
78
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
79
|
+
};
|
|
80
|
+
}, [open, wrapperRef]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/graph/react/viewer/StyleMenu.tsx
|
|
84
|
+
import React3 from "react";
|
|
85
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
86
|
+
var ICON_PROPS = {
|
|
87
|
+
viewBox: "0 0 24 24",
|
|
88
|
+
width: 14,
|
|
89
|
+
height: 14,
|
|
90
|
+
fill: "none",
|
|
91
|
+
stroke: "currentColor",
|
|
92
|
+
strokeWidth: 2,
|
|
93
|
+
strokeLinecap: "round",
|
|
94
|
+
strokeLinejoin: "round"
|
|
95
|
+
};
|
|
96
|
+
var STYLE_ICONS = {
|
|
97
|
+
// Cards with their rows: every pipe with its slots.
|
|
98
|
+
[GRAPH_STYLE.DETAILED]: /* @__PURE__ */ jsxs("svg", __spreadProps(__spreadValues({}, ICON_PROPS), { children: [
|
|
99
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }),
|
|
100
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" }),
|
|
101
|
+
/* @__PURE__ */ jsx("line", { x1: "14", y1: "4", x2: "21", y2: "4" }),
|
|
102
|
+
/* @__PURE__ */ jsx("line", { x1: "14", y1: "9", x2: "21", y2: "9" }),
|
|
103
|
+
/* @__PURE__ */ jsx("line", { x1: "14", y1: "15", x2: "21", y2: "15" }),
|
|
104
|
+
/* @__PURE__ */ jsx("line", { x1: "14", y1: "20", x2: "21", y2: "20" })
|
|
105
|
+
] })),
|
|
106
|
+
// Two steps and the arrow between them: a flowchart.
|
|
107
|
+
[GRAPH_STYLE.SIMPLE]: /* @__PURE__ */ jsxs("svg", __spreadProps(__spreadValues({}, ICON_PROPS), { children: [
|
|
108
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "3", width: "8", height: "8", rx: "2" }),
|
|
109
|
+
/* @__PURE__ */ jsx("path", { d: "M7 11v4a2 2 0 0 0 2 2h4" }),
|
|
110
|
+
/* @__PURE__ */ jsx("rect", { x: "13", y: "13", width: "8", height: "8", rx: "2" })
|
|
111
|
+
] }))
|
|
112
|
+
};
|
|
113
|
+
var CHECK_ICON = /* @__PURE__ */ jsx("svg", __spreadProps(__spreadValues({}, ICON_PROPS), { children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" }) }));
|
|
114
|
+
function styleMenuLabel(style) {
|
|
115
|
+
return `Graph style: ${GRAPH_STYLES[style].name} \u2014 choose how the graph is drawn`;
|
|
116
|
+
}
|
|
117
|
+
var GRAPH_STYLE_MENU_ENTRIES = {
|
|
118
|
+
[GRAPH_STYLE.DETAILED]: __spreadProps(__spreadValues({}, GRAPH_STYLES[GRAPH_STYLE.DETAILED]), { icon: STYLE_ICONS.detailed }),
|
|
119
|
+
[GRAPH_STYLE.SIMPLE]: __spreadProps(__spreadValues({}, GRAPH_STYLES[GRAPH_STYLE.SIMPLE]), { icon: STYLE_ICONS.simple })
|
|
120
|
+
};
|
|
121
|
+
function StyleMenu({
|
|
122
|
+
value,
|
|
123
|
+
options,
|
|
124
|
+
onChange,
|
|
125
|
+
placement,
|
|
126
|
+
entries,
|
|
127
|
+
menuLabel,
|
|
128
|
+
buttonLabel,
|
|
129
|
+
buttonClassName
|
|
130
|
+
}) {
|
|
131
|
+
const [open, setOpen] = React3.useState(false);
|
|
132
|
+
const [activeIndex, setActiveIndex] = React3.useState(0);
|
|
133
|
+
const wrapperRef = React3.useRef(null);
|
|
134
|
+
const buttonRef = React3.useRef(null);
|
|
135
|
+
const itemRefs = React3.useRef([]);
|
|
136
|
+
const menuId = React3.useId();
|
|
137
|
+
usePopoverDismiss(open, wrapperRef, (reason) => {
|
|
138
|
+
var _a;
|
|
139
|
+
setOpen(false);
|
|
140
|
+
if (reason === "escape") (_a = buttonRef.current) == null ? void 0 : _a.focus();
|
|
141
|
+
});
|
|
142
|
+
React3.useEffect(() => {
|
|
143
|
+
var _a;
|
|
144
|
+
if (!open) return;
|
|
145
|
+
const index = Math.max(0, options.indexOf(value));
|
|
146
|
+
setActiveIndex(index);
|
|
147
|
+
(_a = itemRefs.current[index]) == null ? void 0 : _a.focus();
|
|
148
|
+
}, [open]);
|
|
149
|
+
const focusItem = (index) => {
|
|
150
|
+
var _a;
|
|
151
|
+
const count = options.length;
|
|
152
|
+
const next = (index % count + count) % count;
|
|
153
|
+
setActiveIndex(next);
|
|
154
|
+
(_a = itemRefs.current[next]) == null ? void 0 : _a.focus();
|
|
155
|
+
};
|
|
156
|
+
const onMenuKeyDown = (event) => {
|
|
157
|
+
switch (event.key) {
|
|
158
|
+
case "ArrowDown":
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
focusItem(activeIndex + 1);
|
|
161
|
+
break;
|
|
162
|
+
case "ArrowUp":
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
focusItem(activeIndex - 1);
|
|
165
|
+
break;
|
|
166
|
+
case "Home":
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
focusItem(0);
|
|
169
|
+
break;
|
|
170
|
+
case "End":
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
focusItem(options.length - 1);
|
|
173
|
+
break;
|
|
174
|
+
case "Tab":
|
|
175
|
+
setOpen(false);
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const choose = (style) => {
|
|
182
|
+
var _a;
|
|
183
|
+
setOpen(false);
|
|
184
|
+
(_a = buttonRef.current) == null ? void 0 : _a.focus();
|
|
185
|
+
if (style !== value) onChange(style);
|
|
186
|
+
};
|
|
187
|
+
const label = buttonLabel(value);
|
|
188
|
+
return /* @__PURE__ */ jsxs("div", { className: "graph-toolbar-style", ref: wrapperRef, children: [
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
"button",
|
|
191
|
+
{
|
|
192
|
+
ref: buttonRef,
|
|
193
|
+
type: "button",
|
|
194
|
+
className: `${buttonClassName}${open ? ` ${buttonClassName}--open` : ""}`,
|
|
195
|
+
onClick: () => setOpen(!open),
|
|
196
|
+
onKeyDown: (event) => {
|
|
197
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
198
|
+
event.preventDefault();
|
|
199
|
+
setOpen(true);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
title: label,
|
|
203
|
+
"aria-label": label,
|
|
204
|
+
"aria-haspopup": "menu",
|
|
205
|
+
"aria-expanded": open,
|
|
206
|
+
"aria-controls": open ? menuId : void 0,
|
|
207
|
+
children: entries[value].icon
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
open && /* @__PURE__ */ jsx(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
id: menuId,
|
|
214
|
+
role: "menu",
|
|
215
|
+
"aria-label": menuLabel,
|
|
216
|
+
className: `graph-style-menu graph-style-menu--${placement}`,
|
|
217
|
+
onKeyDown: onMenuKeyDown,
|
|
218
|
+
children: options.map((style, index) => {
|
|
219
|
+
const descriptor = entries[style];
|
|
220
|
+
const checked = style === value;
|
|
221
|
+
return /* @__PURE__ */ jsxs(
|
|
222
|
+
"button",
|
|
223
|
+
{
|
|
224
|
+
ref: (el) => {
|
|
225
|
+
itemRefs.current[index] = el;
|
|
226
|
+
},
|
|
227
|
+
type: "button",
|
|
228
|
+
role: "menuitemradio",
|
|
229
|
+
"aria-checked": checked,
|
|
230
|
+
tabIndex: index === activeIndex ? 0 : -1,
|
|
231
|
+
className: `graph-style-menu-item${checked ? " graph-style-menu-item--checked" : ""}`,
|
|
232
|
+
onClick: () => choose(style),
|
|
233
|
+
children: [
|
|
234
|
+
/* @__PURE__ */ jsx("span", { className: "graph-style-menu-icon", "aria-hidden": "true", children: descriptor.icon }),
|
|
235
|
+
/* @__PURE__ */ jsxs("span", { className: "graph-style-menu-text", children: [
|
|
236
|
+
/* @__PURE__ */ jsx("span", { className: "graph-style-menu-name", children: descriptor.name }),
|
|
237
|
+
/* @__PURE__ */ jsx("span", { className: "graph-style-menu-description", children: descriptor.description })
|
|
238
|
+
] }),
|
|
239
|
+
/* @__PURE__ */ jsx("span", { className: "graph-style-menu-check", "aria-hidden": "true", children: checked ? CHECK_ICON : null })
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
style
|
|
243
|
+
);
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
] });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export {
|
|
251
|
+
detectSystemTheme,
|
|
252
|
+
useSystemTheme,
|
|
253
|
+
usePopoverDismiss,
|
|
254
|
+
styleMenuLabel,
|
|
255
|
+
GRAPH_STYLE_MENU_ENTRIES,
|
|
256
|
+
StyleMenu
|
|
257
|
+
};
|
|
258
|
+
//# sourceMappingURL=chunk-7JZBXBZS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/react/viewer/useSystemTheme.ts","../src/graph/react/viewer/usePopoverDismiss.ts","../src/graph/react/viewer/StyleMenu.tsx"],"sourcesContent":["/**\n * Resolve the host environment's color scheme to a binary `GraphTheme`.\n *\n * In a browser this follows `prefers-color-scheme` live. Non-browser hosts (a\n * VS Code webview, where `prefers-color-scheme` is historically flaky) stay\n * authoritative by injecting `systemTheme` — the hook then returns it verbatim\n * and re-renders are driven by the host updating that value.\n *\n * Keeping the `matchMedia` logic in a hook (not inline in GraphViewer) mirrors\n * how the standalone isolated it for testing, and lets the pure\n * `detectSystemTheme` seam be unit-tested without rendering.\n */\nimport React from \"react\";\nimport { GRAPH_THEME, type GraphTheme } from \"@graph/types\";\n\nconst PREFERS_DARK_QUERY = \"(prefers-color-scheme: dark)\";\n\n/** Map a `prefers-color-scheme: dark` match result to a resolved theme. */\nexport function prefersDarkToTheme(prefersDark: boolean): GraphTheme {\n return prefersDark ? GRAPH_THEME.DARK : GRAPH_THEME.LIGHT;\n}\n\n/**\n * Read the environment's current color scheme once. SSR / no-`matchMedia` safe:\n * defaults to `dark` when `window.matchMedia` is unavailable. Exported so\n * non-React callers (e.g. the standalone adapter's initial body-palette paint,\n * before any `onThemeChange` fires) can resolve `system` the same way the hook does.\n */\nexport function detectSystemTheme(): GraphTheme {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return GRAPH_THEME.DARK;\n }\n return prefersDarkToTheme(window.matchMedia(PREFERS_DARK_QUERY).matches);\n}\n\n/**\n * Subscribe to `prefers-color-scheme` changes, invoking `onChange` on each flip.\n * Returns an unsubscribe. SSR / no-`matchMedia` safe: returns a no-op.\n *\n * Older WebKit, some Electron builds, and certain VS Code webview hosts expose\n * a `MediaQueryList` with only the legacy `addListener`/`removeListener` API.\n * Calling `addEventListener` unconditionally throws there — and because this\n * runs inside the `useSyncExternalStore` subscribe during render, the throw\n * crashes the whole GraphViewer (blank graph) on exactly the webview host\n * class the `systemTheme` prop exists to support. Prefer the modern API, fall\n * back to the legacy one (mirrors the deleted standalone `pageTheme.ts`).\n *\n * Exported as a pure seam so the modern/legacy/SSR branches can be unit-tested\n * in a node env (no renderer) — see `__tests__/useSystemTheme.test.ts`.\n */\nexport function subscribeToSystemTheme(onChange: () => void): () => void {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return () => {};\n }\n const mql = window.matchMedia(PREFERS_DARK_QUERY);\n if (typeof mql.addEventListener === \"function\") {\n mql.addEventListener(\"change\", onChange);\n return () => mql.removeEventListener(\"change\", onChange);\n }\n mql.addListener(onChange);\n return () => mql.removeListener(onChange);\n}\n\n/** The `useSyncExternalStore` triple `useSystemTheme` drives. */\nexport interface SystemThemeStore {\n subscribe: (onChange: () => void) => () => void;\n getSnapshot: () => GraphTheme;\n getServerSnapshot: () => GraphTheme;\n}\n\n/**\n * Build the `useSyncExternalStore` triple for a given `injected` value.\n *\n * - `injected` set → host owns detection: `subscribe` is a no-op (no live\n * `matchMedia` listener is ever registered) and both snapshots return\n * `injected`. Spending an OS listener + per-render `detectSystemTheme` on a\n * result we'd discard is pure waste — and wrong to keep alive on the very\n * webview hosts where `prefers-color-scheme` is unreliable.\n * - otherwise → subscribe to `prefers-color-scheme` live; the server snapshot\n * falls back to `dark` (see `docs/theming.md` → \"SSR\").\n *\n * Pure + exported so the injected-skip path is unit-testable without a renderer.\n */\nexport function systemThemeStore(injected?: GraphTheme): SystemThemeStore {\n if (injected !== undefined) {\n return {\n subscribe: () => () => {},\n getSnapshot: () => injected,\n getServerSnapshot: () => injected,\n };\n }\n return {\n subscribe: subscribeToSystemTheme,\n getSnapshot: detectSystemTheme,\n getServerSnapshot: () => GRAPH_THEME.DARK,\n };\n}\n\n/**\n * Resolved environment theme.\n *\n * - `injected` set → return it (host owns detection; host re-renders drive\n * updates). No live `matchMedia` subscription is registered.\n * - otherwise → subscribe to `prefers-color-scheme` and re-render on `change`.\n *\n * Uses `useSyncExternalStore` so the subscription is concurrent-safe. The hook\n * is always called (rules-of-hooks); only the `systemThemeStore` triple branches\n * on `injected`, memoized so the `subscribe` reference stays stable across\n * renders (no re-subscribe churn). SSR with no injected value falls back to\n * `dark` via the server snapshot — see `docs/theming.md` → \"SSR\" for the\n * consequence and the recommended `theme` / `systemTheme` pinning.\n */\nexport function useSystemTheme(injected?: GraphTheme): GraphTheme {\n const store = React.useMemo(() => systemThemeStore(injected), [injected]);\n return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);\n}\n","import React from \"react\";\n\n/** Why an open popover asked to close: a press outside it, or the Escape key. */\nexport type PopoverDismissReason = \"outside\" | \"escape\";\n\n/**\n * Close a toolbar popover (the validation dropdown, the style menu) on a press\n * outside its wrapper or on Escape, while it is open. The listeners live on the\n * document only while `open` is true. `onDismiss` may change between renders\n * without re-registering them.\n *\n * The press is heard in the capture phase: the graph's pane handles its own\n * presses for panning and stops them there, so a listener waiting for them to\n * bubble to the document never hears a press on the canvas, the most common\n * place to click away from a popover.\n */\nexport function usePopoverDismiss(\n open: boolean,\n wrapperRef: React.RefObject<HTMLElement | null>,\n onDismiss: (reason: PopoverDismissReason) => void,\n): void {\n const onDismissRef = React.useRef(onDismiss);\n onDismissRef.current = onDismiss;\n React.useEffect(() => {\n if (!open) return;\n const onPointerDown = (event: PointerEvent) => {\n const wrapper = wrapperRef.current;\n if (wrapper && event.target instanceof Node && !wrapper.contains(event.target)) {\n onDismissRef.current(\"outside\");\n }\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") onDismissRef.current(\"escape\");\n };\n document.addEventListener(\"pointerdown\", onPointerDown, true);\n document.addEventListener(\"keydown\", onKeyDown);\n return () => {\n document.removeEventListener(\"pointerdown\", onPointerDown, true);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [open, wrapperRef]);\n}\n","import React from \"react\";\nimport { GRAPH_STYLE, type GraphStyleId } from \"@graph/types\";\nimport { GRAPH_STYLES } from \"@graph/styles/graphStyles\";\nimport type { ValidationPanelPlacement } from \"./ValidationPanel\";\nimport { usePopoverDismiss } from \"./usePopoverDismiss\";\n\nconst ICON_PROPS = {\n viewBox: \"0 0 24 24\",\n width: 14,\n height: 14,\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2,\n strokeLinecap: \"round\" as const,\n strokeLinejoin: \"round\" as const,\n};\n\n/**\n * Each style's icon, on the toolbar button (the current style) and in its menu\n * row. Keyed by `GraphStyleId`, so a new style does not compile without one.\n */\nconst STYLE_ICONS: Record<GraphStyleId, React.ReactElement> = {\n // Cards with their rows: every pipe with its slots.\n [GRAPH_STYLE.DETAILED]: (\n <svg {...ICON_PROPS}>\n <rect x=\"3\" y=\"3\" width=\"7\" height=\"7\" rx=\"1\" />\n <rect x=\"3\" y=\"14\" width=\"7\" height=\"7\" rx=\"1\" />\n <line x1=\"14\" y1=\"4\" x2=\"21\" y2=\"4\" />\n <line x1=\"14\" y1=\"9\" x2=\"21\" y2=\"9\" />\n <line x1=\"14\" y1=\"15\" x2=\"21\" y2=\"15\" />\n <line x1=\"14\" y1=\"20\" x2=\"21\" y2=\"20\" />\n </svg>\n ),\n // Two steps and the arrow between them: a flowchart.\n [GRAPH_STYLE.SIMPLE]: (\n <svg {...ICON_PROPS}>\n <rect x=\"3\" y=\"3\" width=\"8\" height=\"8\" rx=\"2\" />\n <path d=\"M7 11v4a2 2 0 0 0 2 2h4\" />\n <rect x=\"13\" y=\"13\" width=\"8\" height=\"8\" rx=\"2\" />\n </svg>\n ),\n};\n\nconst CHECK_ICON = (\n <svg {...ICON_PROPS}>\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n);\n\n/** Accessible label of the menu button: the current style, and what the button does. */\nexport function styleMenuLabel(style: GraphStyleId): string {\n return `Graph style: ${GRAPH_STYLES[style].name} — choose how the graph is drawn`;\n}\n\n/** What a style menu shows of one style: its name, its one-line description and its icon. */\nexport interface StyleMenuEntry {\n name: string;\n description: string;\n icon: React.ReactElement;\n}\n\n/** The graph's styles as its menu shows them. */\nexport const GRAPH_STYLE_MENU_ENTRIES: Record<GraphStyleId, StyleMenuEntry> = {\n [GRAPH_STYLE.DETAILED]: { ...GRAPH_STYLES[GRAPH_STYLE.DETAILED], icon: STYLE_ICONS.detailed },\n [GRAPH_STYLE.SIMPLE]: { ...GRAPH_STYLES[GRAPH_STYLE.SIMPLE], icon: STYLE_ICONS.simple },\n};\n\nexport interface StyleMenuProps<Id extends string> {\n /** The active style, shown on the button and checked in the list. */\n value: Id;\n /** The styles offered, in order. */\n options: readonly Id[];\n onChange: (style: Id) => void;\n /** Where the list opens, from the button — the validation dropdown's vocabulary. */\n placement: ValidationPanelPlacement;\n /** Each style's name, description and icon. */\n entries: Readonly<Record<Id, StyleMenuEntry>>;\n /** The menu's accessible name: \"Graph style\". */\n menuLabel: string;\n /** The button's accessible label for the active style. */\n buttonLabel: (style: Id) => string;\n /** The button's class, and with `--open` its class while the list is open. */\n buttonClassName: string;\n}\n\n/**\n * A style menu: a button showing the current style's icon, opening a list of\n * radio items, each with its icon, name and one-line description, and a check\n * on the current one. A list rather than a two-state toggle, because a style\n * registry is built for more than two styles. Keyboard: arrows, Home and End\n * move, Enter or Space choose, Escape closes and returns to the button. The\n * graph's toolbar shows it over the graph's styles, and the run timeline's\n * header over the timeline's.\n */\nexport function StyleMenu<Id extends string>({\n value,\n options,\n onChange,\n placement,\n entries,\n menuLabel,\n buttonLabel,\n buttonClassName,\n}: StyleMenuProps<Id>) {\n const [open, setOpen] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(0);\n const wrapperRef = React.useRef<HTMLDivElement | null>(null);\n const buttonRef = React.useRef<HTMLButtonElement | null>(null);\n const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);\n // useId, not a constant: several viewers can coexist on one page.\n const menuId = React.useId();\n\n usePopoverDismiss(open, wrapperRef, (reason) => {\n setOpen(false);\n if (reason === \"escape\") buttonRef.current?.focus();\n });\n\n // Opening moves focus to the checked item, as a radio menu does.\n React.useEffect(() => {\n if (!open) return;\n const index = Math.max(0, options.indexOf(value));\n setActiveIndex(index);\n itemRefs.current[index]?.focus();\n // Only on opening: choosing a style closes the menu anyway.\n }, [open]);\n\n const focusItem = (index: number) => {\n const count = options.length;\n const next = ((index % count) + count) % count;\n setActiveIndex(next);\n itemRefs.current[next]?.focus();\n };\n\n const onMenuKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n focusItem(activeIndex + 1);\n break;\n case \"ArrowUp\":\n event.preventDefault();\n focusItem(activeIndex - 1);\n break;\n case \"Home\":\n event.preventDefault();\n focusItem(0);\n break;\n case \"End\":\n event.preventDefault();\n focusItem(options.length - 1);\n break;\n case \"Tab\":\n setOpen(false);\n break;\n default:\n break;\n }\n };\n\n const choose = (style: Id) => {\n setOpen(false);\n buttonRef.current?.focus();\n if (style !== value) onChange(style);\n };\n\n const label = buttonLabel(value);\n return (\n <div className=\"graph-toolbar-style\" ref={wrapperRef}>\n <button\n ref={buttonRef}\n type=\"button\"\n className={`${buttonClassName}${open ? ` ${buttonClassName}--open` : \"\"}`}\n onClick={() => setOpen(!open)}\n onKeyDown={(event) => {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n setOpen(true);\n }\n }}\n title={label}\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-controls={open ? menuId : undefined}\n >\n {entries[value].icon}\n </button>\n {open && (\n <div\n id={menuId}\n role=\"menu\"\n aria-label={menuLabel}\n className={`graph-style-menu graph-style-menu--${placement}`}\n onKeyDown={onMenuKeyDown}\n >\n {options.map((style, index) => {\n const descriptor = entries[style];\n const checked = style === value;\n return (\n <button\n key={style}\n ref={(el) => {\n itemRefs.current[index] = el;\n }}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={checked}\n tabIndex={index === activeIndex ? 0 : -1}\n className={`graph-style-menu-item${checked ? \" graph-style-menu-item--checked\" : \"\"}`}\n onClick={() => choose(style)}\n >\n <span className=\"graph-style-menu-icon\" aria-hidden=\"true\">\n {descriptor.icon}\n </span>\n <span className=\"graph-style-menu-text\">\n <span className=\"graph-style-menu-name\">{descriptor.name}</span>\n <span className=\"graph-style-menu-description\">{descriptor.description}</span>\n </span>\n <span className=\"graph-style-menu-check\" aria-hidden=\"true\">\n {checked ? CHECK_ICON : null}\n </span>\n </button>\n );\n })}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,OAAO,WAAW;AAGlB,IAAM,qBAAqB;AAGpB,SAAS,mBAAmB,aAAkC;AACnE,SAAO,cAAc,YAAY,OAAO,YAAY;AACtD;AAQO,SAAS,oBAAgC;AAC9C,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,YAAY;AAAA,EACrB;AACA,SAAO,mBAAmB,OAAO,WAAW,kBAAkB,EAAE,OAAO;AACzE;AAiBO,SAAS,uBAAuB,UAAkC;AACvE,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACA,QAAM,MAAM,OAAO,WAAW,kBAAkB;AAChD,MAAI,OAAO,IAAI,qBAAqB,YAAY;AAC9C,QAAI,iBAAiB,UAAU,QAAQ;AACvC,WAAO,MAAM,IAAI,oBAAoB,UAAU,QAAQ;AAAA,EACzD;AACA,MAAI,YAAY,QAAQ;AACxB,SAAO,MAAM,IAAI,eAAe,QAAQ;AAC1C;AAsBO,SAAS,iBAAiB,UAAyC;AACxE,MAAI,aAAa,QAAW;AAC1B,WAAO;AAAA,MACL,WAAW,MAAM,MAAM;AAAA,MAAC;AAAA,MACxB,aAAa,MAAM;AAAA,MACnB,mBAAmB,MAAM;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,aAAa;AAAA,IACb,mBAAmB,MAAM,YAAY;AAAA,EACvC;AACF;AAgBO,SAAS,eAAe,UAAmC;AAChE,QAAM,QAAQ,MAAM,QAAQ,MAAM,iBA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gC,qBAAW,aAAY;AAAA,mBACzE;AAAA,gBACA,oBAAC,UAAK,WAAU,0BAAyB,eAAY,QAClD,oBAAU,aAAa,MAC1B;AAAA;AAAA;AAAA,YApBK;AAAA,UAqBP;AAAA,QAEJ,CAAC;AAAA;AAAA,IACH;AAAA,KAEJ;AAEJ;","names":["React","React","React"]}
|
|
@@ -3,8 +3,14 @@ import {
|
|
|
3
3
|
parsePipeRef
|
|
4
4
|
} from "./chunk-2N65P32H.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
conceptPlainName,
|
|
7
|
+
humanizeIdentifier,
|
|
8
|
+
humanizeInSentence,
|
|
9
|
+
isGenericConcept,
|
|
10
|
+
outcomeLabel,
|
|
11
|
+
pipeTitle,
|
|
12
|
+
stripDomain
|
|
13
|
+
} from "./chunk-P6IGZVWE.js";
|
|
8
14
|
import {
|
|
9
15
|
ARROW_CLOSED_MARKER,
|
|
10
16
|
BINDING_STEP_TYPE,
|
|
@@ -1905,179 +1911,6 @@ function sortParentsFirst(nodes) {
|
|
|
1905
1911
|
return [...nodes].sort((a, b) => depthOf[a.id] - depthOf[b.id]);
|
|
1906
1912
|
}
|
|
1907
1913
|
|
|
1908
|
-
// src/graph/styles/graphStyles.ts
|
|
1909
|
-
var GRAPH_STYLES = {
|
|
1910
|
-
[GRAPH_STYLE.DETAILED]: {
|
|
1911
|
-
id: GRAPH_STYLE.DETAILED,
|
|
1912
|
-
name: "Detailed",
|
|
1913
|
-
description: "Every pipe with its inputs, outputs and settings",
|
|
1914
|
-
capabilities: { controllerFrameToggle: true, foldAll: true }
|
|
1915
|
-
},
|
|
1916
|
-
[GRAPH_STYLE.SIMPLE]: {
|
|
1917
|
-
id: GRAPH_STYLE.SIMPLE,
|
|
1918
|
-
name: "Simple",
|
|
1919
|
-
description: "The method's steps in plain words",
|
|
1920
|
-
capabilities: { controllerFrameToggle: false, foldAll: true },
|
|
1921
|
-
layout: {
|
|
1922
|
-
nodesep: 28,
|
|
1923
|
-
ranksep: 44,
|
|
1924
|
-
routeEdges: true,
|
|
1925
|
-
groupPadding: { x: 20, top: 40, bottom: 16 }
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
};
|
|
1929
|
-
var GRAPH_STYLE_IDS = [GRAPH_STYLE.DETAILED, GRAPH_STYLE.SIMPLE];
|
|
1930
|
-
function isGraphStyleId(value) {
|
|
1931
|
-
return typeof value === "string" && Object.hasOwn(GRAPH_STYLES, value);
|
|
1932
|
-
}
|
|
1933
|
-
function resolveGraphStyle(styleProp, configStyle) {
|
|
1934
|
-
if (isGraphStyleId(styleProp)) return styleProp;
|
|
1935
|
-
if (isGraphStyleId(configStyle)) return configStyle;
|
|
1936
|
-
return DEFAULT_GRAPH_CONFIG.graphStyle;
|
|
1937
|
-
}
|
|
1938
|
-
function resolveStyleMenu(styleMenu) {
|
|
1939
|
-
if (styleMenu === void 0 || styleMenu === false) return [];
|
|
1940
|
-
const requested = styleMenu === true ? GRAPH_STYLE_IDS : styleMenu;
|
|
1941
|
-
const offered = [];
|
|
1942
|
-
for (const id of requested) {
|
|
1943
|
-
if (isGraphStyleId(id) && !offered.includes(id)) offered.push(id);
|
|
1944
|
-
}
|
|
1945
|
-
return offered.length >= 2 ? offered : [];
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
// src/graph/styles/humanize.ts
|
|
1949
|
-
var VOWELED_ACRONYMS = /* @__PURE__ */ new Set([
|
|
1950
|
-
"ai",
|
|
1951
|
-
"api",
|
|
1952
|
-
"faq",
|
|
1953
|
-
"iban",
|
|
1954
|
-
"id",
|
|
1955
|
-
"io",
|
|
1956
|
-
"ip",
|
|
1957
|
-
"json",
|
|
1958
|
-
"kpi",
|
|
1959
|
-
"ocr",
|
|
1960
|
-
"roi",
|
|
1961
|
-
"seo",
|
|
1962
|
-
"ui",
|
|
1963
|
-
"uri",
|
|
1964
|
-
"url",
|
|
1965
|
-
"uuid",
|
|
1966
|
-
"ux"
|
|
1967
|
-
]);
|
|
1968
|
-
var VOWELS = /[aeiouy]/;
|
|
1969
|
-
var VOWELLESS_WORDS = /* @__PURE__ */ new Set([
|
|
1970
|
-
"cfg",
|
|
1971
|
-
"cm",
|
|
1972
|
-
"cnt",
|
|
1973
|
-
"ctx",
|
|
1974
|
-
"dr",
|
|
1975
|
-
"dst",
|
|
1976
|
-
"fn",
|
|
1977
|
-
"ft",
|
|
1978
|
-
"hmm",
|
|
1979
|
-
"hr",
|
|
1980
|
-
"kg",
|
|
1981
|
-
"km",
|
|
1982
|
-
"lb",
|
|
1983
|
-
"mg",
|
|
1984
|
-
"ml",
|
|
1985
|
-
"mm",
|
|
1986
|
-
"mr",
|
|
1987
|
-
"mrs",
|
|
1988
|
-
"ms",
|
|
1989
|
-
"msg",
|
|
1990
|
-
"nd",
|
|
1991
|
-
"nth",
|
|
1992
|
-
"pkg",
|
|
1993
|
-
"pt",
|
|
1994
|
-
"rd",
|
|
1995
|
-
"src",
|
|
1996
|
-
"st",
|
|
1997
|
-
"th",
|
|
1998
|
-
"tmp",
|
|
1999
|
-
"vs"
|
|
2000
|
-
]);
|
|
2001
|
-
var SINGULAR_S_ACRONYMS = /* @__PURE__ */ new Set([
|
|
2002
|
-
"cms",
|
|
2003
|
-
"css",
|
|
2004
|
-
"dns",
|
|
2005
|
-
"gps",
|
|
2006
|
-
"rss",
|
|
2007
|
-
"sms"
|
|
2008
|
-
]);
|
|
2009
|
-
var NATIVE_PLAIN_NAMES = {
|
|
2010
|
-
Html: "HTML",
|
|
2011
|
-
JSON: "JSON",
|
|
2012
|
-
TextAndImages: "Text and images",
|
|
2013
|
-
YesNo: "Yes or no",
|
|
2014
|
-
SearchResult: "Search result",
|
|
2015
|
-
Composite: "Combined results",
|
|
2016
|
-
Dynamic: "Data"
|
|
2017
|
-
};
|
|
2018
|
-
var GENERIC_NATIVES = /* @__PURE__ */ new Set(["Anything", "Dynamic", "Composite"]);
|
|
2019
|
-
function isAcronymWord(lower) {
|
|
2020
|
-
if (lower.length < 2 || !/^[a-z]+$/.test(lower)) return false;
|
|
2021
|
-
if (VOWELLESS_WORDS.has(lower)) return false;
|
|
2022
|
-
if (lower.endsWith("s") && VOWELLESS_WORDS.has(lower.slice(0, -1))) return false;
|
|
2023
|
-
return !VOWELS.test(lower) || VOWELED_ACRONYMS.has(lower);
|
|
2024
|
-
}
|
|
2025
|
-
function spellWord(lower, wasAllCaps) {
|
|
2026
|
-
if (/^\d+$/.test(lower)) return lower;
|
|
2027
|
-
if (wasAllCaps && lower.length >= 2) return lower.toUpperCase();
|
|
2028
|
-
if (lower.endsWith("s") && !SINGULAR_S_ACRONYMS.has(lower) && isAcronymWord(lower.slice(0, -1))) {
|
|
2029
|
-
return lower.slice(0, -1).toUpperCase() + "s";
|
|
2030
|
-
}
|
|
2031
|
-
if (isAcronymWord(lower)) return lower.toUpperCase();
|
|
2032
|
-
return lower;
|
|
2033
|
-
}
|
|
2034
|
-
function splitIdentifier(identifier) {
|
|
2035
|
-
const parts = identifier.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/([A-Za-z])(\d)/g, "$1 $2").split(/[\s_\-.]+/).filter((p) => p.length > 0);
|
|
2036
|
-
return parts.map((p) => ({
|
|
2037
|
-
word: p.toLowerCase(),
|
|
2038
|
-
wasAllCaps: p.length >= 2 && p === p.toUpperCase() && /[A-Z]/.test(p)
|
|
2039
|
-
}));
|
|
2040
|
-
}
|
|
2041
|
-
function capitalizeFirst(text) {
|
|
2042
|
-
return text.length === 0 ? text : text.charAt(0).toUpperCase() + text.slice(1);
|
|
2043
|
-
}
|
|
2044
|
-
function stripDomain(ref) {
|
|
2045
|
-
const dot = ref.lastIndexOf(".");
|
|
2046
|
-
return dot === -1 ? ref : ref.slice(dot + 1);
|
|
2047
|
-
}
|
|
2048
|
-
function humanizeIdentifier(identifier) {
|
|
2049
|
-
const words = splitIdentifier(stripDomain(identifier.trim()));
|
|
2050
|
-
if (words.length === 0) return "";
|
|
2051
|
-
return capitalizeFirst(words.map((w) => spellWord(w.word, w.wasAllCaps)).join(" "));
|
|
2052
|
-
}
|
|
2053
|
-
function conceptPlainName(conceptRef) {
|
|
2054
|
-
var _a;
|
|
2055
|
-
const code = stripDomain(conceptRef.trim());
|
|
2056
|
-
return (_a = NATIVE_PLAIN_NAMES[code]) != null ? _a : humanizeIdentifier(code);
|
|
2057
|
-
}
|
|
2058
|
-
function isGenericConcept(conceptRef) {
|
|
2059
|
-
return GENERIC_NATIVES.has(stripDomain(conceptRef.trim()));
|
|
2060
|
-
}
|
|
2061
|
-
function sentenceCase(text) {
|
|
2062
|
-
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
2063
|
-
const trimmed = collapsed.endsWith(".") && !collapsed.endsWith("..") ? collapsed.slice(0, -1) : collapsed;
|
|
2064
|
-
return capitalizeFirst(trimmed);
|
|
2065
|
-
}
|
|
2066
|
-
var OUTCOME_WORDS = {
|
|
2067
|
-
true: "Yes",
|
|
2068
|
-
false: "No",
|
|
2069
|
-
default: "Otherwise"
|
|
2070
|
-
};
|
|
2071
|
-
function outcomeLabel(outcome) {
|
|
2072
|
-
const outcomes = outcome.split("|").map((o) => o.trim()).filter((o) => o.length > 0);
|
|
2073
|
-
const labels = outcomes.map((o, index) => {
|
|
2074
|
-
var _a;
|
|
2075
|
-
const label = (_a = OUTCOME_WORDS[o.toLowerCase()]) != null ? _a : humanizeIdentifier(o);
|
|
2076
|
-
return index === 0 ? label : label.charAt(0).toLowerCase() + label.slice(1);
|
|
2077
|
-
});
|
|
2078
|
-
return labels.join(" or ");
|
|
2079
|
-
}
|
|
2080
|
-
|
|
2081
1914
|
// src/graph/styles/textMetrics.ts
|
|
2082
1915
|
var GLYPH_EM_GROUPS = [
|
|
2083
1916
|
[0.28, "il .,'"],
|
|
@@ -2340,14 +2173,10 @@ function stepIdentity(spec) {
|
|
|
2340
2173
|
return `${spec.kind}:${ref}`;
|
|
2341
2174
|
}
|
|
2342
2175
|
function forEachLabel(itemName) {
|
|
2343
|
-
|
|
2344
|
-
const words = humanizeIdentifier(itemName);
|
|
2345
|
-
const first = (_a = words.split(" ")[0]) != null ? _a : "";
|
|
2346
|
-
const inSentence = first.length >= 2 && first === first.toUpperCase() ? words : words.charAt(0).toLowerCase() + words.slice(1);
|
|
2347
|
-
return `For each ${inSentence}`;
|
|
2176
|
+
return `For each ${humanizeInSentence(itemName)}`;
|
|
2348
2177
|
}
|
|
2349
2178
|
function projectSimpleGraph(input) {
|
|
2350
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
2179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2351
2180
|
const { graphspec, nodes, analysis, rawAnalysis } = input;
|
|
2352
2181
|
const graphMode = graphSpecMode(graphspec);
|
|
2353
2182
|
const specById = new Map(graphspec.nodes.map((n) => [n.id, n]));
|
|
@@ -2695,7 +2524,7 @@ function projectSimpleGraph(input) {
|
|
|
2695
2524
|
return counted.reduce((sum, child) => sum + stepsInside(child), 0);
|
|
2696
2525
|
}
|
|
2697
2526
|
function stepTitle(spec, folded) {
|
|
2698
|
-
var _a2, _b2, _c2, _d2, _e2
|
|
2527
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
2699
2528
|
if (spec.pipe_type === BINDING_STEP_TYPE) {
|
|
2700
2529
|
return humanizeIdentifier((_b2 = (_a2 = spec.pipe_code) == null ? void 0 : _a2.split(".").pop()) != null ? _b2 : "");
|
|
2701
2530
|
}
|
|
@@ -2704,8 +2533,7 @@ function projectSimpleGraph(input) {
|
|
|
2704
2533
|
const branch = specById.get((_d2 = (_c2 = rawAnalysis.containmentTree[spec.id]) == null ? void 0 : _c2[0]) != null ? _d2 : "");
|
|
2705
2534
|
if (branch) source = branch;
|
|
2706
2535
|
}
|
|
2707
|
-
|
|
2708
|
-
return described || humanizeIdentifier((_f2 = source.pipe_code) != null ? _f2 : "");
|
|
2536
|
+
return pipeTitle(source.description, (_e2 = source.pipe_code) != null ? _e2 : "").title;
|
|
2709
2537
|
}
|
|
2710
2538
|
const stepById = new Map(drawnSteps.map((card) => [card.id, card]));
|
|
2711
2539
|
for (const spec of graphspec.nodes) {
|
|
@@ -2749,7 +2577,7 @@ function projectSimpleGraph(input) {
|
|
|
2749
2577
|
continue;
|
|
2750
2578
|
}
|
|
2751
2579
|
if (decisionSet.has(spec.id)) {
|
|
2752
|
-
const title =
|
|
2580
|
+
const title = pipeTitle(spec.description, (_i = spec.pipe_code) != null ? _i : "").title;
|
|
2753
2581
|
simpleNodes.push({
|
|
2754
2582
|
id: spec.id,
|
|
2755
2583
|
type: NODE_TYPE_SIMPLE_DECISION,
|
|
@@ -3019,17 +2847,6 @@ export {
|
|
|
3019
2847
|
buildControllerNodes,
|
|
3020
2848
|
applyControllers,
|
|
3021
2849
|
sortParentsFirst,
|
|
3022
|
-
GRAPH_STYLES,
|
|
3023
|
-
GRAPH_STYLE_IDS,
|
|
3024
|
-
isGraphStyleId,
|
|
3025
|
-
resolveGraphStyle,
|
|
3026
|
-
resolveStyleMenu,
|
|
3027
|
-
stripDomain,
|
|
3028
|
-
humanizeIdentifier,
|
|
3029
|
-
conceptPlainName,
|
|
3030
|
-
isGenericConcept,
|
|
3031
|
-
sentenceCase,
|
|
3032
|
-
outcomeLabel,
|
|
3033
2850
|
textWidthPx,
|
|
3034
2851
|
estimateWrap,
|
|
3035
2852
|
SIMPLE_STEP_WIDTH,
|
|
@@ -3052,4 +2869,4 @@ export {
|
|
|
3052
2869
|
applySimpleFrames,
|
|
3053
2870
|
GRAPH_STYLE_PIPELINES
|
|
3054
2871
|
};
|
|
3055
|
-
//# sourceMappingURL=chunk-
|
|
2872
|
+
//# sourceMappingURL=chunk-HPARBH6K.js.map
|