@motifx-community/ui 0.1.0-beta.16 → 0.1.0-beta.17
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 +32 -0
- package/dist/components/diagram/Diagram.d.ts +92 -0
- package/dist/components/diagram/DiagramEdgeView.d.ts +14 -4
- package/dist/components/diagram/DiagramLinks.d.ts +2 -0
- package/dist/components/diagram/DiagramNodeView.d.ts +19 -1
- package/dist/components/diagram/diagram-change.d.ts +3 -2
- package/dist/components/diagram/diagram-edge-click-event-args.d.ts +21 -0
- package/dist/components/diagram/diagram-edge-pointer-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-edge.d.ts +8 -0
- package/dist/components/diagram/diagram-links-host.d.ts +3 -0
- package/dist/components/diagram/diagram-node-click-event-args.d.ts +23 -0
- package/dist/components/diagram/diagram-node-context.d.ts +5 -0
- package/dist/components/diagram/diagram-node-host.d.ts +4 -0
- package/dist/components/diagram/diagram-node-pointer-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-props.d.ts +45 -0
- package/dist/components/diagram/diagram-text-changed-event-args.d.ts +7 -0
- package/dist/components/diagram/diagram-text-changing-event-args.d.ts +14 -0
- package/dist/components/diagram/diagram-text-editing-event-args.d.ts +11 -0
- package/dist/components/diagram/index.d.ts +7 -0
- package/dist/core/ui-strings.d.ts +5 -0
- package/dist/index.js +2096 -1557
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +3 -0
- package/dist/locales/tr.json +3 -0
- package/dist/styles.css +54 -0
- package/dist/{tr-4GNbFdQh.js → tr-CMuuXBUb.js} +8 -2
- package/dist/{tr-4GNbFdQh.js.map → tr-CMuuXBUb.js.map} +1 -1
- package/docs/accordion.md +1 -1
- package/docs/actionsheet.md +1 -1
- package/docs/appbar.md +1 -1
- package/docs/appmenu-api.md +1 -1
- package/docs/appmenu-programmatic.md +1 -1
- package/docs/appmenu-search.md +1 -1
- package/docs/appmenu.md +1 -1
- package/docs/avatar.md +1 -1
- package/docs/badge.md +1 -1
- package/docs/bar-gauge-angles.md +1 -1
- package/docs/bar-gauge-data.md +1 -1
- package/docs/bar-gauge-labels.md +1 -1
- package/docs/bar-gauge.md +1 -1
- package/docs/barcode.md +1 -1
- package/docs/bottomnavigation.md +1 -1
- package/docs/bottomsheet.md +1 -1
- package/docs/breadcrumb.md +1 -1
- package/docs/button.md +1 -1
- package/docs/buttongroup.md +1 -1
- package/docs/buttons.md +1 -1
- package/docs/calendar.md +1 -1
- package/docs/card.md +1 -1
- package/docs/chart-bars.md +1 -1
- package/docs/chart-candles.md +1 -1
- package/docs/chart-funnel.md +1 -1
- package/docs/chart-heatmap.md +1 -1
- package/docs/chart-lines.md +1 -1
- package/docs/chart-live.md +1 -1
- package/docs/chart-pie.md +1 -1
- package/docs/chart-radar.md +1 -1
- package/docs/chart-ranges.md +1 -1
- package/docs/chart-references.md +1 -1
- package/docs/chart-scatter.md +1 -1
- package/docs/chart-waterfall.md +1 -1
- package/docs/chart-zoom.md +1 -1
- package/docs/chart.md +1 -1
- package/docs/chat.md +1 -1
- package/docs/checkbox.md +1 -1
- package/docs/chip.md +1 -1
- package/docs/choice.md +1 -1
- package/docs/colorbox.md +1 -1
- package/docs/combobox.md +1 -1
- package/docs/commands.md +1 -1
- package/docs/control.md +1 -1
- package/docs/data.md +1 -1
- package/docs/datagrid-api.md +1 -1
- package/docs/datagrid-bands.md +1 -1
- package/docs/datagrid-drag-select.md +1 -1
- package/docs/datagrid-drag.md +1 -1
- package/docs/datagrid-editing.md +1 -1
- package/docs/datagrid-filtering.md +1 -1
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +1 -1
- package/docs/datagrid-layout.md +1 -1
- package/docs/datagrid-lookups.md +1 -1
- package/docs/datagrid-master-detail.md +1 -1
- package/docs/datagrid-scrolling.md +1 -1
- package/docs/datagrid-selection.md +1 -1
- package/docs/datagrid.md +1 -1
- package/docs/datebox.md +1 -1
- package/docs/daterangebox.md +1 -1
- package/docs/diagram-api.md +19 -4
- package/docs/diagram-commands.md +2 -1
- package/docs/diagram-connections.md +8 -6
- package/docs/diagram-custom-nodes.md +1 -1
- package/docs/diagram-designer.md +1 -1
- package/docs/diagram-editing.md +132 -5
- package/docs/diagram-flow.md +21 -4
- package/docs/diagram-keyboard.md +5 -1
- package/docs/diagram-layout.md +1 -1
- package/docs/diagram-nodes.md +1 -1
- package/docs/diagram-tables.md +1 -1
- package/docs/diagram.md +11 -8
- package/docs/display.md +1 -1
- package/docs/draggable.md +1 -1
- package/docs/drawer.md +1 -1
- package/docs/dropdown.md +1 -1
- package/docs/editors.md +1 -1
- package/docs/expressioneditor.md +1 -1
- package/docs/expressions.md +1 -1
- package/docs/feedback.md +1 -1
- package/docs/fileuploader.md +1 -1
- package/docs/filterbuilder.md +1 -1
- package/docs/formlayout-schema.md +1 -1
- package/docs/formlayout.md +1 -1
- package/docs/foundations.md +1 -1
- package/docs/gallery.md +1 -1
- package/docs/gauge-base.md +1 -1
- package/docs/gauge-circular.md +1 -1
- package/docs/gauge-dashboards.md +1 -1
- package/docs/gauge-linear.md +1 -1
- package/docs/gauge-markers.md +1 -1
- package/docs/gauge-marks.md +1 -1
- package/docs/gauge-ranges.md +1 -1
- package/docs/gauge-scales.md +1 -1
- package/docs/gauge.md +1 -1
- package/docs/home.md +1 -1
- package/docs/keyboard.md +1 -1
- package/docs/language.md +1 -1
- package/docs/layout.md +1 -1
- package/docs/listbox.md +1 -1
- package/docs/loadpanel.md +1 -1
- package/docs/lookup.md +1 -1
- package/docs/markdown.md +1 -1
- package/docs/menus-api.md +1 -1
- package/docs/menus-context.md +1 -1
- package/docs/menus-customization.md +1 -1
- package/docs/menus-merging.md +1 -1
- package/docs/menus-programmatic.md +1 -1
- package/docs/menus.md +1 -1
- package/docs/multiview.md +1 -1
- package/docs/navigation.md +1 -1
- package/docs/numberbox.md +1 -1
- package/docs/otpinput.md +1 -1
- package/docs/pagination.md +1 -1
- package/docs/pivotgrid-api.md +1 -1
- package/docs/pivotgrid-chart.md +1 -1
- package/docs/pivotgrid-drilldown.md +1 -1
- package/docs/pivotgrid-export.md +1 -1
- package/docs/pivotgrid-fields.md +1 -1
- package/docs/pivotgrid-keyboard.md +1 -1
- package/docs/pivotgrid-layout.md +1 -1
- package/docs/pivotgrid-panel.md +1 -1
- package/docs/pivotgrid-remote.md +1 -1
- package/docs/pivotgrid-sorting.md +1 -1
- package/docs/pivotgrid-state.md +1 -1
- package/docs/pivotgrid-summaries.md +1 -1
- package/docs/pivotgrid.md +1 -1
- package/docs/popover.md +1 -1
- package/docs/progress.md +1 -1
- package/docs/qrcode.md +1 -1
- package/docs/radiogroup.md +1 -1
- package/docs/rating.md +1 -1
- package/docs/resizable.md +1 -1
- package/docs/ribbonmenu-api.md +1 -1
- package/docs/ribbonmenu-commands.md +1 -1
- package/docs/ribbonmenu-customization.md +1 -1
- package/docs/ribbonmenu-display.md +1 -1
- package/docs/ribbonmenu-layouts.md +1 -1
- package/docs/ribbonmenu-programmatic.md +1 -1
- package/docs/ribbonmenu.md +1 -1
- package/docs/scheduler-agenda.md +1 -1
- package/docs/scheduler-big-data.md +1 -1
- package/docs/scheduler-editing.md +1 -1
- package/docs/scheduler-form.md +1 -1
- package/docs/scheduler-icalendar.md +1 -1
- package/docs/scheduler-mobile.md +1 -1
- package/docs/scheduler-recurrence.md +1 -1
- package/docs/scheduler-resources.md +1 -1
- package/docs/scheduler-timeline.md +1 -1
- package/docs/scheduler.md +1 -1
- package/docs/scrollview.md +1 -1
- package/docs/shortcuteditor.md +1 -1
- package/docs/showcase-flowstudio.md +1 -1
- package/docs/showcase-home.md +1 -1
- package/docs/showcase-mail.md +1 -1
- package/docs/showcase.md +1 -1
- package/docs/signature.md +1 -1
- package/docs/skeleton.md +1 -1
- package/docs/slider.md +1 -1
- package/docs/sortable.md +1 -1
- package/docs/sparkline.md +1 -1
- package/docs/speeddial.md +1 -1
- package/docs/splitter.md +1 -1
- package/docs/stepper.md +1 -1
- package/docs/switch.md +1 -1
- package/docs/tabdocs-dock.md +1 -1
- package/docs/tabdocs-drag.md +1 -1
- package/docs/tabdocs-menus.md +1 -1
- package/docs/tabdocs-mobile.md +1 -1
- package/docs/tabdocs-tabs.md +1 -1
- package/docs/tabdocs-windows.md +1 -1
- package/docs/tabdocs-workspace.md +1 -1
- package/docs/tabdocs.md +1 -1
- package/docs/tabs.md +1 -1
- package/docs/tagbox.md +1 -1
- package/docs/textarea.md +1 -1
- package/docs/textbox.md +1 -1
- package/docs/tileview.md +1 -1
- package/docs/timeline.md +1 -1
- package/docs/toast.md +1 -1
- package/docs/tokens.md +1 -1
- package/docs/toolbar-api.md +1 -1
- package/docs/toolbar-customization.md +1 -1
- package/docs/toolbar.md +1 -1
- package/docs/tooltip.md +1 -1
- package/docs/treeview.md +1 -1
- package/docs/validationsummary.md +1 -1
- package/docs/window.md +1 -1
- package/docs/wizard.md +1 -1
- package/llms-full.txt +382 -213
- package/llms.txt +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -300,7 +300,7 @@ function pendingScroll(component) {
|
|
|
300
300
|
//#endregion
|
|
301
301
|
//#region src/core/measure/scroll-memory.ts
|
|
302
302
|
var known$1 = /* @__PURE__ */ new WeakMap();
|
|
303
|
-
var heard = /* @__PURE__ */ new WeakSet();
|
|
303
|
+
var heard$1 = /* @__PURE__ */ new WeakSet();
|
|
304
304
|
/** Elements scrolled and not read yet, and the ones of each window that wait for its next frame. */
|
|
305
305
|
var unread = /* @__PURE__ */ new WeakSet();
|
|
306
306
|
var waiting$2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -310,8 +310,8 @@ var AT_START = {
|
|
|
310
310
|
};
|
|
311
311
|
/** Notes from now on how far the elements of `view` are scrolled. */
|
|
312
312
|
function rememberScrolls(view) {
|
|
313
|
-
if (heard.has(view)) return;
|
|
314
|
-
heard.add(view);
|
|
313
|
+
if (heard$1.has(view)) return;
|
|
314
|
+
heard$1.add(view);
|
|
315
315
|
onDocument(view.document, "scroll", (e) => {
|
|
316
316
|
const el = e.target;
|
|
317
317
|
if (!isElement(el)) return;
|
|
@@ -3295,6 +3295,7 @@ var en_exports = /* @__PURE__ */ __exportAll({
|
|
|
3295
3295
|
diagramDuplicate: () => diagramDuplicate,
|
|
3296
3296
|
diagramEdgeIs: () => diagramEdgeIs,
|
|
3297
3297
|
diagramEdgeLabelIs: () => diagramEdgeLabelIs,
|
|
3298
|
+
diagramEdgeName: () => diagramEdgeName,
|
|
3298
3299
|
diagramEndsFixed: () => diagramEndsFixed,
|
|
3299
3300
|
diagramExpand: () => diagramExpand,
|
|
3300
3301
|
diagramFit: () => diagramFit,
|
|
@@ -3318,6 +3319,7 @@ var en_exports = /* @__PURE__ */ __exportAll({
|
|
|
3318
3319
|
diagramReconnected: () => diagramReconnected,
|
|
3319
3320
|
diagramRedo: () => diagramRedo,
|
|
3320
3321
|
diagramRedone: () => diagramRedone,
|
|
3322
|
+
diagramRename: () => diagramRename,
|
|
3321
3323
|
diagramReshaped: () => diagramReshaped,
|
|
3322
3324
|
diagramResized: () => diagramResized,
|
|
3323
3325
|
diagramRole: () => diagramRole,
|
|
@@ -3329,6 +3331,7 @@ var en_exports = /* @__PURE__ */ __exportAll({
|
|
|
3329
3331
|
diagramStatusSaid: () => diagramStatusSaid,
|
|
3330
3332
|
diagramStatusSkipped: () => diagramStatusSkipped,
|
|
3331
3333
|
diagramStatusWaiting: () => diagramStatusWaiting,
|
|
3334
|
+
diagramTextEditor: () => diagramTextEditor,
|
|
3332
3335
|
diagramUndo: () => diagramUndo,
|
|
3333
3336
|
diagramUndone: () => diagramUndone,
|
|
3334
3337
|
diagramZoomIn: () => diagramZoomIn,
|
|
@@ -5219,6 +5222,9 @@ var diagramStatusError = "Failed";
|
|
|
5219
5222
|
var diagramStatusWaiting = "Waiting";
|
|
5220
5223
|
var diagramStatusSkipped = "Skipped";
|
|
5221
5224
|
var diagramStatusSaid = "{name}: {status}.";
|
|
5225
|
+
var diagramEdgeName = "Connection from {source} to {target}";
|
|
5226
|
+
var diagramRename = "Rename";
|
|
5227
|
+
var diagramTextEditor = "Text of {name}";
|
|
5222
5228
|
var expressionEditorSuggestions = "Suggestions";
|
|
5223
5229
|
var expressionProblemUnexpectedEnd = "The expression ends too soon: {expected} is missing.";
|
|
5224
5230
|
var expressionProblemUnexpectedToken = "{found} was not expected here; {expected} was.";
|
|
@@ -6344,6 +6350,9 @@ var en_default = {
|
|
|
6344
6350
|
diagramStatusWaiting,
|
|
6345
6351
|
diagramStatusSkipped,
|
|
6346
6352
|
diagramStatusSaid,
|
|
6353
|
+
diagramEdgeName,
|
|
6354
|
+
diagramRename,
|
|
6355
|
+
diagramTextEditor,
|
|
6347
6356
|
expressionEditorSuggestions,
|
|
6348
6357
|
expressionProblemUnexpectedEnd,
|
|
6349
6358
|
expressionProblemUnexpectedToken,
|
|
@@ -6645,7 +6654,7 @@ function startLocale() {
|
|
|
6645
6654
|
*/
|
|
6646
6655
|
var uiLocale = new UiLocale(enStrings, (language) => _rolldown_dynamic_import_helper_default(/* #__PURE__ */ Object.assign({
|
|
6647
6656
|
"../locales/en.json": () => Promise.resolve().then(() => en_exports),
|
|
6648
|
-
"../locales/tr.json": () => import("./tr-
|
|
6657
|
+
"../locales/tr.json": () => import("./tr-CMuuXBUb.js")
|
|
6649
6658
|
}), `../locales/${language}.json`, 3), startLocale());
|
|
6650
6659
|
//#endregion
|
|
6651
6660
|
//#region src/core/access-key.ts
|
|
@@ -108098,6 +108107,10 @@ function rowSide(port) {
|
|
|
108098
108107
|
const sides = typeof port.side === "string" ? [port.side] : port.side;
|
|
108099
108108
|
return port.label && sides.length === 1 && (sides[0] === "left" || sides[0] === "right") ? sides[0] : null;
|
|
108100
108109
|
}
|
|
108110
|
+
/** The rows of a side, in the order of their places. */
|
|
108111
|
+
function rowsOf(rows, side) {
|
|
108112
|
+
return [...rows.values()].filter((r) => r.side === side).sort((a, b) => a.at - b.at).map((r) => r.row);
|
|
108113
|
+
}
|
|
108101
108114
|
/**
|
|
108102
108115
|
* A kind of node to start one's own from: a header with an icon, the node's text as the title and a line under it, a
|
|
108103
108116
|
* body of the kind's own, and a row for each port on the left or the right that has a `label`, the port beside its row,
|
|
@@ -108129,6 +108142,7 @@ function cardKind(options = {}) {
|
|
|
108129
108142
|
const icon = part(header, "span", "mx-diagram__card-icon");
|
|
108130
108143
|
const titles = part(header, "div", "mx-diagram__card-titles");
|
|
108131
108144
|
const title = part(titles, "div", "mx-diagram__card-title");
|
|
108145
|
+
context.textPart(title);
|
|
108132
108146
|
const subtitle = part(titles, "div", "mx-diagram__card-subtitle");
|
|
108133
108147
|
let inner = null;
|
|
108134
108148
|
if (options.body) {
|
|
@@ -108172,6 +108186,9 @@ function cardKind(options = {}) {
|
|
|
108172
108186
|
}
|
|
108173
108187
|
kept$2(parts.icon, icon !== void 0);
|
|
108174
108188
|
const seen = /* @__PURE__ */ new Set();
|
|
108189
|
+
let lefts = 0;
|
|
108190
|
+
let rights = 0;
|
|
108191
|
+
let moved = false;
|
|
108175
108192
|
for (const port of portsOf(node)) {
|
|
108176
108193
|
const side = rowSide(port);
|
|
108177
108194
|
if (!side || seen.has(port.id)) continue;
|
|
@@ -108186,11 +108203,17 @@ function cardKind(options = {}) {
|
|
|
108186
108203
|
put(row, "data-side", side);
|
|
108187
108204
|
entry = {
|
|
108188
108205
|
row,
|
|
108189
|
-
side
|
|
108206
|
+
side,
|
|
108207
|
+
at: -1
|
|
108190
108208
|
};
|
|
108191
108209
|
parts.rows.set(port.id, entry);
|
|
108192
108210
|
context.anchor(port.id, row);
|
|
108193
108211
|
}
|
|
108212
|
+
const at = side === "left" ? lefts++ : rights++;
|
|
108213
|
+
if (entry.at !== at) {
|
|
108214
|
+
entry.at = at;
|
|
108215
|
+
moved = true;
|
|
108216
|
+
}
|
|
108194
108217
|
text$1(entry.row, port.label ?? "");
|
|
108195
108218
|
}
|
|
108196
108219
|
for (const [id, entry] of parts.rows) {
|
|
@@ -108199,6 +108222,10 @@ function cardKind(options = {}) {
|
|
|
108199
108222
|
context.anchor(id, null);
|
|
108200
108223
|
removePart(entry.row);
|
|
108201
108224
|
}
|
|
108225
|
+
if (moved) {
|
|
108226
|
+
orderControls(parts.ins, rowsOf(parts.rows, "left"));
|
|
108227
|
+
orderControls(parts.outs, rowsOf(parts.rows, "right"));
|
|
108228
|
+
}
|
|
108202
108229
|
kept$2(parts.ports, parts.rows.size > 0);
|
|
108203
108230
|
if (parts.inner) options.update?.(parts.inner);
|
|
108204
108231
|
}
|
|
@@ -108267,6 +108294,7 @@ function builtInKinds(toggle, check) {
|
|
|
108267
108294
|
const button = toggleOf(context);
|
|
108268
108295
|
header.controls.add(button);
|
|
108269
108296
|
const title = part(header, "div", "mx-diagram__group-title");
|
|
108297
|
+
context.textPart(title);
|
|
108270
108298
|
part(context.host, "div", "mx-diagram__group-body");
|
|
108271
108299
|
context.dragHandle(header);
|
|
108272
108300
|
groups.set(context, {
|
|
@@ -108296,6 +108324,7 @@ function builtInKinds(toggle, check) {
|
|
|
108296
108324
|
const button = toggleOf(context);
|
|
108297
108325
|
header.controls.add(button);
|
|
108298
108326
|
const title = part(header, "div", "mx-diagram__table-title");
|
|
108327
|
+
context.textPart(title);
|
|
108299
108328
|
const rows = part(context.host, "div", "mx-diagram__table-rows");
|
|
108300
108329
|
tables.set(context, {
|
|
108301
108330
|
title,
|
|
@@ -108388,6 +108417,7 @@ function builtInKinds(toggle, check) {
|
|
|
108388
108417
|
const header = part(context.host, "div", "mx-diagram__class-header");
|
|
108389
108418
|
const stereotype = part(header, "div", "mx-diagram__class-stereotype");
|
|
108390
108419
|
const name = part(header, "div", "mx-diagram__class-name");
|
|
108420
|
+
context.textPart(name);
|
|
108391
108421
|
const button = toggleOf(context);
|
|
108392
108422
|
header.controls.add(button);
|
|
108393
108423
|
const attributes = part(context.host, "div", "mx-diagram__class-compartment");
|
|
@@ -111276,726 +111306,1388 @@ function round$2(value) {
|
|
|
111276
111306
|
return Math.round(value * 1e3) / 1e3;
|
|
111277
111307
|
}
|
|
111278
111308
|
//#endregion
|
|
111279
|
-
//#region src/components/diagram/
|
|
111280
|
-
/**
|
|
111281
|
-
var
|
|
111309
|
+
//#region src/components/diagram/DiagramNodeView.ts
|
|
111310
|
+
/** The ports of a node that names none: the middle of each side; a flow comes in at the top and the left and goes out at the right and the bottom. */
|
|
111311
|
+
var SIDE_PORTS = [
|
|
111312
|
+
{
|
|
111313
|
+
id: "top",
|
|
111314
|
+
side: "top",
|
|
111315
|
+
direction: "target"
|
|
111316
|
+
},
|
|
111317
|
+
{
|
|
111318
|
+
id: "right",
|
|
111319
|
+
side: "right",
|
|
111320
|
+
direction: "source"
|
|
111321
|
+
},
|
|
111322
|
+
{
|
|
111323
|
+
id: "bottom",
|
|
111324
|
+
side: "bottom",
|
|
111325
|
+
direction: "source"
|
|
111326
|
+
},
|
|
111327
|
+
{
|
|
111328
|
+
id: "left",
|
|
111329
|
+
side: "left",
|
|
111330
|
+
direction: "target"
|
|
111331
|
+
}
|
|
111332
|
+
];
|
|
111333
|
+
var RESIZE_SIDES = [
|
|
111334
|
+
"n",
|
|
111335
|
+
"ne",
|
|
111336
|
+
"e",
|
|
111337
|
+
"se",
|
|
111338
|
+
"s",
|
|
111339
|
+
"sw",
|
|
111340
|
+
"w",
|
|
111341
|
+
"nw"
|
|
111342
|
+
];
|
|
111343
|
+
var STATUS_WORDS = {
|
|
111344
|
+
running: "diagramStatusRunning",
|
|
111345
|
+
done: "diagramStatusDone",
|
|
111346
|
+
error: "diagramStatusError",
|
|
111347
|
+
waiting: "diagramStatusWaiting",
|
|
111348
|
+
skipped: "diagramStatusSkipped"
|
|
111349
|
+
};
|
|
111350
|
+
/** What a node's status says, in the kit's language: its word, and the node's `statusText` after it. */
|
|
111351
|
+
function statusWords(status, detail) {
|
|
111352
|
+
const word = uiLocale.strings[STATUS_WORDS[status]] ?? status;
|
|
111353
|
+
return detail ? `${word}: ${detail}` : word;
|
|
111354
|
+
}
|
|
111282
111355
|
/**
|
|
111283
|
-
* A
|
|
111284
|
-
*
|
|
111285
|
-
* (a line out of view in a large diagram).
|
|
111356
|
+
* A node on the surface: the app's object drawn at its place with the content of its kind, its ports and, when it may
|
|
111357
|
+
* be resized, its resize handles; its size measured as it is laid out.
|
|
111286
111358
|
*/
|
|
111287
|
-
var
|
|
111288
|
-
constructor(
|
|
111289
|
-
_defineProperty(this, "
|
|
111290
|
-
_defineProperty(this, "labels", void 0);
|
|
111291
|
-
_defineProperty(this, "told", void 0);
|
|
111292
|
-
_defineProperty(this, "parts", null);
|
|
111359
|
+
var DiagramNodeView = class {
|
|
111360
|
+
constructor(node, host) {
|
|
111361
|
+
_defineProperty(this, "part", void 0);
|
|
111293
111362
|
_defineProperty(
|
|
111294
111363
|
this,
|
|
111295
|
-
/**
|
|
111296
|
-
"
|
|
111297
|
-
|
|
111364
|
+
/** Where the content of its kind goes: its text, or what the kind made. */
|
|
111365
|
+
"body",
|
|
111366
|
+
void 0
|
|
111298
111367
|
);
|
|
111299
|
-
_defineProperty(this, "selected", false);
|
|
111300
|
-
_defineProperty(this, "moving", false);
|
|
111301
|
-
_defineProperty(this, "label", null);
|
|
111302
111368
|
_defineProperty(
|
|
111303
111369
|
this,
|
|
111304
|
-
/** The
|
|
111305
|
-
"
|
|
111306
|
-
|
|
111307
|
-
source: null,
|
|
111308
|
-
target: null
|
|
111309
|
-
}
|
|
111370
|
+
/** The id of its element, which the diagram names as the active node to a screen reader. */
|
|
111371
|
+
"elementId",
|
|
111372
|
+
nextId("diagram-node")
|
|
111310
111373
|
);
|
|
111374
|
+
_defineProperty(this, "host", void 0);
|
|
111311
111375
|
_defineProperty(
|
|
111312
111376
|
this,
|
|
111313
|
-
/**
|
|
111314
|
-
"
|
|
111315
|
-
|
|
111377
|
+
/** A part for each port on each of its sides, by port and side. */
|
|
111378
|
+
"portParts",
|
|
111379
|
+
/* @__PURE__ */ new Map()
|
|
111316
111380
|
);
|
|
111317
|
-
_defineProperty(this, "
|
|
111318
|
-
_defineProperty(this, "
|
|
111381
|
+
_defineProperty(this, "resizers", /* @__PURE__ */ new Map());
|
|
111382
|
+
_defineProperty(this, "context", void 0);
|
|
111319
111383
|
_defineProperty(
|
|
111320
111384
|
this,
|
|
111321
|
-
/**
|
|
111322
|
-
"
|
|
111323
|
-
|
|
111385
|
+
/** The parts of the content ports stand beside, by port, and where those parts are: the share of the way across and down the node to their middles. */
|
|
111386
|
+
"anchors",
|
|
111387
|
+
/* @__PURE__ */ new Map()
|
|
111324
111388
|
);
|
|
111389
|
+
_defineProperty(this, "offsets", /* @__PURE__ */ new Map());
|
|
111325
111390
|
_defineProperty(
|
|
111326
111391
|
this,
|
|
111327
|
-
/** The
|
|
111328
|
-
"
|
|
111329
|
-
|
|
111392
|
+
/** The ports, as read when it was drawn. */
|
|
111393
|
+
"portList",
|
|
111394
|
+
SIDE_PORTS
|
|
111330
111395
|
);
|
|
111331
|
-
_defineProperty(this, "
|
|
111396
|
+
_defineProperty(this, "label", null);
|
|
111332
111397
|
_defineProperty(
|
|
111333
111398
|
this,
|
|
111334
|
-
/**
|
|
111335
|
-
"
|
|
111399
|
+
/** The mark of its status in its corner, while it has one. */
|
|
111400
|
+
"statusMark",
|
|
111336
111401
|
null
|
|
111337
111402
|
);
|
|
111403
|
+
_defineProperty(this, "kind", null);
|
|
111338
111404
|
_defineProperty(
|
|
111339
111405
|
this,
|
|
111340
|
-
/**
|
|
111341
|
-
"
|
|
111342
|
-
|
|
111343
|
-
);
|
|
111344
|
-
this.edge = edge;
|
|
111345
|
-
this.edges = edges;
|
|
111346
|
-
this.labels = labels;
|
|
111347
|
-
this.told = told;
|
|
111348
|
-
}
|
|
111349
|
-
/** The group of its parts; `null` until it is first shown. */
|
|
111350
|
-
get group() {
|
|
111351
|
-
return this.parts?.group ?? null;
|
|
111352
|
-
}
|
|
111353
|
-
/** Puts it on the page or takes it off: its parts are made the first time. Returns whether they were made now. */
|
|
111354
|
-
setLive(on) {
|
|
111355
|
-
if (this.live === on) return false;
|
|
111356
|
-
this.live = on;
|
|
111357
|
-
if (!on) {
|
|
111358
|
-
kept$2(this.parts?.group ?? null, false);
|
|
111359
|
-
for (const label of [
|
|
111360
|
-
this.label,
|
|
111361
|
-
this.endLabels.source,
|
|
111362
|
-
this.endLabels.target
|
|
111363
|
-
]) kept$2(label, false);
|
|
111364
|
-
return false;
|
|
111365
|
-
}
|
|
111366
|
-
const made = !this.parts && !!this.drawn;
|
|
111367
|
-
this.write();
|
|
111368
|
-
return made;
|
|
111369
|
-
}
|
|
111370
|
-
/**
|
|
111371
|
-
* Draws the line between two points on their nodes, each with the side it leaves by, through the connection's own
|
|
111372
|
-
* points; an orthogonal line goes around `obstacles`, the nodes.
|
|
111373
|
-
*/
|
|
111374
|
-
draw(source, sourceSide, target, targetSide, shape, look, obstacles) {
|
|
111375
|
-
const edge = this.edge;
|
|
111376
|
-
const sourceMarker = edge.sourceMarker ?? "none";
|
|
111377
|
-
const targetMarker = edge.targetMarker ?? "arrow";
|
|
111378
|
-
const route = routeOf(shape, source, sourceSide, target, targetSide, {
|
|
111379
|
-
source: markerInset(sourceMarker, look.marker),
|
|
111380
|
-
target: markerInset(targetMarker, look.marker)
|
|
111381
|
-
}, look, edge.points ?? [], obstacles);
|
|
111382
|
-
this.ends = {
|
|
111383
|
-
source,
|
|
111384
|
-
sourceSide,
|
|
111385
|
-
target,
|
|
111386
|
-
targetSide
|
|
111387
|
-
};
|
|
111388
|
-
this.corners = route.corners;
|
|
111389
|
-
this.shape = shape;
|
|
111390
|
-
this.drawn = {
|
|
111391
|
-
route,
|
|
111392
|
-
sourceMarker,
|
|
111393
|
-
targetMarker,
|
|
111394
|
-
look
|
|
111395
|
-
};
|
|
111396
|
-
const room = look.gap * 2 + look.marker * 2 + (edge.label || edge.sourceLabel || edge.targetLabel ? LABEL_ROOM : 0);
|
|
111397
|
-
this.bounds = boundsAround([
|
|
111398
|
-
source,
|
|
111399
|
-
target,
|
|
111400
|
-
...route.corners
|
|
111401
|
-
], room);
|
|
111402
|
-
if (this.live) this.write();
|
|
111403
|
-
}
|
|
111404
|
-
/** Writes the line as last worked out to its parts, made now if it has none. */
|
|
111405
|
-
write() {
|
|
111406
|
-
const drawn = this.drawn;
|
|
111407
|
-
const ends = this.ends;
|
|
111408
|
-
if (!drawn || !ends) return;
|
|
111409
|
-
const p = this.parts ??= this.make();
|
|
111410
|
-
const { route, sourceMarker, targetMarker, look } = drawn;
|
|
111411
|
-
const edge = this.edge;
|
|
111412
|
-
put(p.group, "data-id", edge.id);
|
|
111413
|
-
mark(p.group, "data-dashed", edge.dashed || edge.animated);
|
|
111414
|
-
mark(p.group, "data-animated", edge.animated);
|
|
111415
|
-
this.drawLook(p.group);
|
|
111416
|
-
kept$2(p.group, true);
|
|
111417
|
-
put(p.line, "d", route.d);
|
|
111418
|
-
put(p.hit, "d", route.d);
|
|
111419
|
-
this.drawMark(p.sourceMark, sourceMarker, ends.source, route.sourceBack, look.marker);
|
|
111420
|
-
this.drawMark(p.targetMark, targetMarker, ends.target, route.targetBack, look.marker);
|
|
111421
|
-
this.drawLabel(route.label);
|
|
111422
|
-
this.drawEndLabel("source", edge.sourceLabel, ends.source, ends.sourceSide, look.marker);
|
|
111423
|
-
this.drawEndLabel("target", edge.targetLabel, ends.target, ends.targetSide, look.marker);
|
|
111424
|
-
}
|
|
111425
|
-
make() {
|
|
111426
|
-
const group = svgComponent(this.edges, "g", "mx-diagram__edge");
|
|
111427
|
-
const parts = {
|
|
111428
|
-
group,
|
|
111429
|
-
hit: svgComponent(group, "path", "mx-diagram__edge-hit"),
|
|
111430
|
-
line: svgComponent(group, "path", "mx-diagram__edge-line"),
|
|
111431
|
-
sourceMark: svgComponent(group, "path", "mx-diagram__edge-marker"),
|
|
111432
|
-
targetMark: svgComponent(group, "path", "mx-diagram__edge-marker")
|
|
111433
|
-
};
|
|
111434
|
-
group.motif.on("pointerdown", (_, e) => this.told.pressed(this, e));
|
|
111435
|
-
group.motif.on("click", (_, e) => this.told.clicked(this, e));
|
|
111436
|
-
mark(group, "data-selected", this.selected);
|
|
111437
|
-
mark(group, "data-moving", this.moving);
|
|
111438
|
-
return parts;
|
|
111439
|
-
}
|
|
111440
|
-
/** Not drawn: one of its nodes is missing or not laid out yet. */
|
|
111441
|
-
hide() {
|
|
111442
|
-
this.ends = null;
|
|
111443
|
-
this.drawn = null;
|
|
111444
|
-
this.bounds = null;
|
|
111445
|
-
kept$2(this.parts?.group ?? null, false);
|
|
111446
|
-
kept$2(this.label, false);
|
|
111447
|
-
kept$2(this.endLabels.source, false);
|
|
111448
|
-
kept$2(this.endLabels.target, false);
|
|
111449
|
-
}
|
|
111450
|
-
/** What an image of the diagram draws of it: its line and marks, and its labels; `null` while it is not drawn or not on the page. */
|
|
111451
|
-
get picture() {
|
|
111452
|
-
const p = this.parts;
|
|
111453
|
-
if (!this.ends || !p || !this.live) return null;
|
|
111454
|
-
const labels = [];
|
|
111455
|
-
for (const label of [
|
|
111456
|
-
this.label,
|
|
111457
|
-
this.endLabels.source,
|
|
111458
|
-
this.endLabels.target
|
|
111459
|
-
]) if (label) labels.push(label);
|
|
111460
|
-
return {
|
|
111461
|
-
marks: [
|
|
111462
|
-
p.line,
|
|
111463
|
-
p.sourceMark,
|
|
111464
|
-
p.targetMark
|
|
111465
|
-
],
|
|
111466
|
-
labels
|
|
111467
|
-
};
|
|
111468
|
-
}
|
|
111469
|
-
/** Marks it while one of its ends is being moved. */
|
|
111470
|
-
markMoving(on) {
|
|
111471
|
-
this.moving = on;
|
|
111472
|
-
if (this.parts) mark(this.parts.group, "data-moving", on);
|
|
111473
|
-
}
|
|
111474
|
-
markSelected(on) {
|
|
111475
|
-
this.selected = on;
|
|
111476
|
-
if (this.parts) mark(this.parts.group, "data-selected", on);
|
|
111477
|
-
for (const label of [
|
|
111478
|
-
this.label,
|
|
111479
|
-
this.endLabels.source,
|
|
111480
|
-
this.endLabels.target
|
|
111481
|
-
]) if (label) mark(label, "data-selected", on);
|
|
111482
|
-
}
|
|
111483
|
-
/** The app's color, width, classes and style properties; those it took away since the last draw come off. */
|
|
111484
|
-
drawLook(group) {
|
|
111485
|
-
const edge = this.edge;
|
|
111486
|
-
css(group, "color", edge.color ?? "");
|
|
111487
|
-
css(group, "--_diagram-edge-width", edge.width != null ? `${edge.width}px` : "");
|
|
111488
|
-
const classes = (edge.cssClass ?? "").split(/\s+/).filter(Boolean);
|
|
111489
|
-
for (const name of this.drawnClasses) if (!classes.includes(name)) toggleClass(group, name, false);
|
|
111490
|
-
for (const name of classes) toggleClass(group, name, true);
|
|
111491
|
-
this.drawnClasses = classes;
|
|
111492
|
-
const style = edge.style ?? {};
|
|
111493
|
-
for (const name of this.drawnStyle) if (!(name in style)) css(group, name, "");
|
|
111494
|
-
for (const [name, value] of Object.entries(style)) css(group, name, value);
|
|
111495
|
-
this.drawnStyle = Object.keys(style);
|
|
111496
|
-
}
|
|
111497
|
-
remove() {
|
|
111498
|
-
removePart(this.label);
|
|
111499
|
-
removePart(this.endLabels.source);
|
|
111500
|
-
removePart(this.endLabels.target);
|
|
111501
|
-
removePart(this.parts?.group ?? null);
|
|
111502
|
-
this.parts = null;
|
|
111503
|
-
}
|
|
111504
|
-
drawMark(markPart, marker, tip, back, size) {
|
|
111505
|
-
put(markPart, "data-shape", marker === "none" ? null : marker);
|
|
111506
|
-
put(markPart, "d", markerPath(marker, tip, back, size) || null);
|
|
111507
|
-
}
|
|
111508
|
-
drawLabel(at) {
|
|
111509
|
-
const value = this.edge.label ?? "";
|
|
111510
|
-
if (!value) {
|
|
111511
|
-
removePart(this.label);
|
|
111512
|
-
this.label = null;
|
|
111513
|
-
return;
|
|
111514
|
-
}
|
|
111515
|
-
if (!this.label) {
|
|
111516
|
-
this.label = part(this.labels, "div", "mx-diagram__edge-label");
|
|
111517
|
-
mark(this.label, "data-selected", this.selected);
|
|
111518
|
-
}
|
|
111519
|
-
text$1(this.label, value);
|
|
111520
|
-
put(this.label, "data-edge", this.edge.id);
|
|
111521
|
-
kept$2(this.label, true);
|
|
111522
|
-
css(this.label, "transform", `translate(${round$1(at.x)}px, ${round$1(at.y)}px) translate(-50%, -50%)`);
|
|
111523
|
-
}
|
|
111524
|
-
/**
|
|
111525
|
-
* The text at an end: by the node, on the side of the line away from its mark's toes; above a line that leaves by a
|
|
111526
|
-
* side, after one that leaves by the top or the bottom.
|
|
111527
|
-
*/
|
|
111528
|
-
drawEndLabel(end, value, tip, side, size) {
|
|
111529
|
-
let label = this.endLabels[end];
|
|
111530
|
-
if (!value) {
|
|
111531
|
-
removePart(label);
|
|
111532
|
-
this.endLabels[end] = null;
|
|
111533
|
-
return;
|
|
111534
|
-
}
|
|
111535
|
-
if (!label) {
|
|
111536
|
-
label = part(this.labels, "div", "mx-diagram__edge-end-label");
|
|
111537
|
-
put(label, "data-end", end);
|
|
111538
|
-
mark(label, "data-selected", this.selected);
|
|
111539
|
-
this.endLabels[end] = label;
|
|
111540
|
-
}
|
|
111541
|
-
text$1(label, value);
|
|
111542
|
-
put(label, "data-edge", this.edge.id);
|
|
111543
|
-
put(label, "data-side", side);
|
|
111544
|
-
kept$2(label, true);
|
|
111545
|
-
const out = size * .4;
|
|
111546
|
-
const aside = size * .5 + 2;
|
|
111547
|
-
const [x, y, shift] = {
|
|
111548
|
-
right: [
|
|
111549
|
-
tip.x + out,
|
|
111550
|
-
tip.y - aside,
|
|
111551
|
-
"0, -100%"
|
|
111552
|
-
],
|
|
111553
|
-
left: [
|
|
111554
|
-
tip.x - out,
|
|
111555
|
-
tip.y - aside,
|
|
111556
|
-
"-100%, -100%"
|
|
111557
|
-
],
|
|
111558
|
-
top: [
|
|
111559
|
-
tip.x + aside,
|
|
111560
|
-
tip.y - out,
|
|
111561
|
-
"0, -100%"
|
|
111562
|
-
],
|
|
111563
|
-
bottom: [
|
|
111564
|
-
tip.x + aside,
|
|
111565
|
-
tip.y + out,
|
|
111566
|
-
"0, 0"
|
|
111567
|
-
]
|
|
111568
|
-
}[side];
|
|
111569
|
-
css(label, "transform", `translate(${round$1(x)}px, ${round$1(y)}px) translate(${shift})`);
|
|
111570
|
-
}
|
|
111571
|
-
};
|
|
111572
|
-
/** The box around `points`, `margin` out of them. */
|
|
111573
|
-
function boundsAround(points, margin) {
|
|
111574
|
-
let left = Infinity;
|
|
111575
|
-
let top = Infinity;
|
|
111576
|
-
let right = -Infinity;
|
|
111577
|
-
let bottom = -Infinity;
|
|
111578
|
-
for (const p of points) {
|
|
111579
|
-
left = Math.min(left, p.x);
|
|
111580
|
-
top = Math.min(top, p.y);
|
|
111581
|
-
right = Math.max(right, p.x);
|
|
111582
|
-
bottom = Math.max(bottom, p.y);
|
|
111583
|
-
}
|
|
111584
|
-
return {
|
|
111585
|
-
x: left - margin,
|
|
111586
|
-
y: top - margin,
|
|
111587
|
-
width: right - left + margin * 2,
|
|
111588
|
-
height: bottom - top + margin * 2
|
|
111589
|
-
};
|
|
111590
|
-
}
|
|
111591
|
-
function round$1(value) {
|
|
111592
|
-
return Math.round(value * 100) / 100;
|
|
111593
|
-
}
|
|
111594
|
-
//#endregion
|
|
111595
|
-
//#region src/components/diagram/DiagramLinks.ts
|
|
111596
|
-
/** How far a press moves before it draws a connection and is not a click, in pixels. */
|
|
111597
|
-
var DRAG_FROM$2 = 3;
|
|
111598
|
-
/** The way into a node through each side, for the end of a line drawn to the pointer. */
|
|
111599
|
-
var FACING$1 = {
|
|
111600
|
-
top: "bottom",
|
|
111601
|
-
right: "left",
|
|
111602
|
-
bottom: "top",
|
|
111603
|
-
left: "right"
|
|
111604
|
-
};
|
|
111605
|
-
/** The way out of a node through each side. */
|
|
111606
|
-
var OUT = {
|
|
111607
|
-
top: {
|
|
111608
|
-
x: 0,
|
|
111609
|
-
y: -1
|
|
111610
|
-
},
|
|
111611
|
-
right: {
|
|
111612
|
-
x: 1,
|
|
111613
|
-
y: 0
|
|
111614
|
-
},
|
|
111615
|
-
bottom: {
|
|
111616
|
-
x: 0,
|
|
111617
|
-
y: 1
|
|
111618
|
-
},
|
|
111619
|
-
left: {
|
|
111620
|
-
x: -1,
|
|
111621
|
-
y: 0
|
|
111622
|
-
}
|
|
111623
|
-
};
|
|
111624
|
-
/** Whether a port starts connections (`'source'`) or ends them (`'target'`). */
|
|
111625
|
-
function serves(port, end) {
|
|
111626
|
-
return !port.direction || port.direction === "both" || port.direction === end;
|
|
111627
|
-
}
|
|
111628
|
-
/**
|
|
111629
|
-
* The connections of a diagram: a line for each, matched by `id`; only the lines of what changed are drawn again. A
|
|
111630
|
-
* drag from a port draws a new connection, and a drag of an end moves it, both under the diagram's rules.
|
|
111631
|
-
*/
|
|
111632
|
-
var DiagramLinks = class {
|
|
111633
|
-
constructor(surface, edgeLayer, labelLayer, handleLayer, host) {
|
|
111634
|
-
_defineProperty(this, "surface", void 0);
|
|
111635
|
-
_defineProperty(this, "edgeLayer", void 0);
|
|
111636
|
-
_defineProperty(this, "labelLayer", void 0);
|
|
111637
|
-
_defineProperty(this, "handleLayer", void 0);
|
|
111638
|
-
_defineProperty(this, "host", void 0);
|
|
111639
|
-
_defineProperty(this, "autoPan", void 0);
|
|
111640
|
-
_defineProperty(
|
|
111641
|
-
this,
|
|
111642
|
-
/** The handles that move, add and take away the points of the selected lines; the keys do the same through it. */
|
|
111643
|
-
"bends",
|
|
111644
|
-
void 0
|
|
111645
|
-
);
|
|
111646
|
-
_defineProperty(this, "views", /* @__PURE__ */ new Map());
|
|
111647
|
-
_defineProperty(
|
|
111648
|
-
this,
|
|
111649
|
-
/** The selected connections, by `id`, and the handles over their ends, which take an end to move it. */
|
|
111650
|
-
"selected",
|
|
111651
|
-
/* @__PURE__ */ new Set()
|
|
111406
|
+
/** The kind whose content it holds now. */
|
|
111407
|
+
"made",
|
|
111408
|
+
null
|
|
111652
111409
|
);
|
|
111653
|
-
_defineProperty(this, "handles", /* @__PURE__ */ new Map());
|
|
111654
111410
|
_defineProperty(
|
|
111655
111411
|
this,
|
|
111656
|
-
/**
|
|
111657
|
-
"
|
|
111658
|
-
|
|
111412
|
+
/** Whether its content is made and laid out: it came into view once, or the diagram shows every node. */
|
|
111413
|
+
"entered",
|
|
111414
|
+
false
|
|
111659
111415
|
);
|
|
111660
111416
|
_defineProperty(
|
|
111661
111417
|
this,
|
|
111662
|
-
/**
|
|
111663
|
-
"
|
|
111664
|
-
|
|
111418
|
+
/** Whether it is on the page: it lies in view, or the diagram shows every node. */
|
|
111419
|
+
"live",
|
|
111420
|
+
true
|
|
111665
111421
|
);
|
|
111666
111422
|
_defineProperty(
|
|
111667
111423
|
this,
|
|
111668
|
-
/**
|
|
111669
|
-
"
|
|
111670
|
-
|
|
111424
|
+
/** The part a press drags the node from, when the kind's content named one. */
|
|
111425
|
+
"handle",
|
|
111426
|
+
null
|
|
111671
111427
|
);
|
|
111672
111428
|
_defineProperty(
|
|
111673
111429
|
this,
|
|
111674
|
-
/** The
|
|
111675
|
-
"
|
|
111676
|
-
|
|
111430
|
+
/** The part that shows its text, when the kind's content named one (`context.textPart`). */
|
|
111431
|
+
"textHolder",
|
|
111432
|
+
null
|
|
111677
111433
|
);
|
|
111678
111434
|
_defineProperty(
|
|
111679
111435
|
this,
|
|
111680
|
-
/**
|
|
111681
|
-
"
|
|
111682
|
-
|
|
111436
|
+
/** The editor of its text, over the part that shows it, while the text is edited. */
|
|
111437
|
+
"editor",
|
|
111438
|
+
null
|
|
111683
111439
|
);
|
|
111684
111440
|
_defineProperty(
|
|
111685
111441
|
this,
|
|
111686
|
-
/**
|
|
111687
|
-
|
|
111688
|
-
* reach into `outer`, the selected and the one whose end is moved; `null` puts every line on the page.
|
|
111689
|
-
*/
|
|
111690
|
-
"region",
|
|
111442
|
+
/** What names it, when the kind's content gave it (`context.label`), and what stops the name following its data. */
|
|
111443
|
+
"naming",
|
|
111691
111444
|
null
|
|
111692
111445
|
);
|
|
111446
|
+
_defineProperty(this, "stopNaming", null);
|
|
111693
111447
|
_defineProperty(
|
|
111694
111448
|
this,
|
|
111695
|
-
/** The
|
|
111696
|
-
"
|
|
111449
|
+
/** The app's and the kind's classes and the app's style properties written last, so those taken away come off. */
|
|
111450
|
+
"drawnClasses",
|
|
111697
111451
|
[]
|
|
111698
111452
|
);
|
|
111453
|
+
_defineProperty(this, "drawnStyle", []);
|
|
111454
|
+
_defineProperty(this, "node", void 0);
|
|
111699
111455
|
_defineProperty(
|
|
111700
111456
|
this,
|
|
111701
|
-
/**
|
|
111702
|
-
"
|
|
111703
|
-
|
|
111457
|
+
/** Its border box as laid out, in the diagram's units: the zoom is a transform and does not change it. */
|
|
111458
|
+
"size",
|
|
111459
|
+
{
|
|
111460
|
+
width: 0,
|
|
111461
|
+
height: 0
|
|
111462
|
+
}
|
|
111704
111463
|
);
|
|
111705
111464
|
_defineProperty(
|
|
111706
111465
|
this,
|
|
111707
|
-
/**
|
|
111708
|
-
"
|
|
111709
|
-
|
|
111466
|
+
/** Hidden in a collapsed group. */
|
|
111467
|
+
"hidden",
|
|
111468
|
+
false
|
|
111710
111469
|
);
|
|
111711
|
-
_defineProperty(this, "look", {
|
|
111712
|
-
marker: 10,
|
|
111713
|
-
corner: 8,
|
|
111714
|
-
gap: 20
|
|
111715
|
-
});
|
|
111716
111470
|
_defineProperty(
|
|
111717
111471
|
this,
|
|
111718
|
-
/**
|
|
111719
|
-
"
|
|
111720
|
-
|
|
111472
|
+
/** The share of the way across and down the node to the middle of each part a port stands beside; a part not laid out is left out. */
|
|
111473
|
+
"anchorsRead",
|
|
111474
|
+
() => {
|
|
111475
|
+
const offsets = /* @__PURE__ */ new Map();
|
|
111476
|
+
const box = rectOf(this.part);
|
|
111477
|
+
if (box.width <= 0 || box.height <= 0) return offsets;
|
|
111478
|
+
for (const [id, at] of this.anchors) {
|
|
111479
|
+
const r = rectOf(at);
|
|
111480
|
+
if (r.width <= 0 && r.height <= 0) continue;
|
|
111481
|
+
offsets.set(id, {
|
|
111482
|
+
across: (r.left + r.width / 2 - box.left) / box.width,
|
|
111483
|
+
down: (r.top + r.height / 2 - box.top) / box.height
|
|
111484
|
+
});
|
|
111485
|
+
}
|
|
111486
|
+
return offsets;
|
|
111487
|
+
}
|
|
111721
111488
|
);
|
|
111722
111489
|
_defineProperty(
|
|
111723
111490
|
this,
|
|
111724
|
-
/**
|
|
111725
|
-
|
|
111726
|
-
|
|
111727
|
-
|
|
111728
|
-
|
|
111729
|
-
|
|
111730
|
-
|
|
111731
|
-
|
|
111732
|
-
|
|
111733
|
-
|
|
111734
|
-
|
|
111735
|
-
/**
|
|
111736
|
-
* Set while nodes glide to their places: the lines that go around the nodes are drawn as if nothing stood in their
|
|
111737
|
-
* way, which is quick, and find their way again once the nodes stand still.
|
|
111738
|
-
*/
|
|
111739
|
-
"quick",
|
|
111740
|
-
false
|
|
111491
|
+
/** The ports stand where their parts are now; their connections are drawn again. */
|
|
111492
|
+
"anchorsWritten",
|
|
111493
|
+
(offsets) => {
|
|
111494
|
+
if (offsets.size === this.offsets.size && [...offsets].every(([id, at]) => {
|
|
111495
|
+
const was = this.offsets.get(id);
|
|
111496
|
+
return !!was && Math.abs(was.across - at.across) < 1e-4 && Math.abs(was.down - at.down) < 1e-4;
|
|
111497
|
+
})) return;
|
|
111498
|
+
this.offsets = offsets;
|
|
111499
|
+
this.drawPorts();
|
|
111500
|
+
this.host.sized(this);
|
|
111501
|
+
}
|
|
111741
111502
|
);
|
|
111742
|
-
this.
|
|
111743
|
-
this.edgeLayer = edgeLayer;
|
|
111744
|
-
this.labelLayer = labelLayer;
|
|
111745
|
-
this.handleLayer = handleLayer;
|
|
111503
|
+
this.node = node;
|
|
111746
111504
|
this.host = host;
|
|
111747
|
-
this.
|
|
111748
|
-
|
|
111749
|
-
|
|
111750
|
-
|
|
111751
|
-
|
|
111752
|
-
|
|
111753
|
-
|
|
111754
|
-
|
|
111755
|
-
|
|
111756
|
-
|
|
111757
|
-
host.askDraw();
|
|
111505
|
+
this.part = loose("div", "mx-diagram__node");
|
|
111506
|
+
this.part.attr.add({
|
|
111507
|
+
id: this.elementId,
|
|
111508
|
+
role: "group"
|
|
111509
|
+
});
|
|
111510
|
+
this.body = part(this.part, "div", "mx-diagram__node-content");
|
|
111511
|
+
const view = this;
|
|
111512
|
+
this.context = {
|
|
111513
|
+
get node() {
|
|
111514
|
+
return view.node;
|
|
111758
111515
|
},
|
|
111759
|
-
|
|
111760
|
-
|
|
111516
|
+
host: this.body,
|
|
111517
|
+
diagram: host.diagram,
|
|
111518
|
+
get selected() {
|
|
111519
|
+
return host.isSelected(view);
|
|
111520
|
+
},
|
|
111521
|
+
dragHandle(handle) {
|
|
111522
|
+
view.handle = handle;
|
|
111523
|
+
},
|
|
111524
|
+
anchor(id, at) {
|
|
111525
|
+
if (at) view.anchors.set(id, at);
|
|
111526
|
+
else view.anchors.delete(id);
|
|
111527
|
+
view.readAnchors();
|
|
111528
|
+
},
|
|
111529
|
+
label(read) {
|
|
111530
|
+
view.stopNaming?.();
|
|
111531
|
+
view.naming = read;
|
|
111532
|
+
view.stopNaming = effect(() => {
|
|
111533
|
+
const name = read();
|
|
111534
|
+
untracked(() => put(view.part, "aria-label", name || view.node.id));
|
|
111535
|
+
});
|
|
111536
|
+
},
|
|
111537
|
+
textPart(at) {
|
|
111538
|
+
view.textHolder = at;
|
|
111539
|
+
}
|
|
111540
|
+
};
|
|
111541
|
+
this.part.motif.setDisposable(() => this.stopNaming?.());
|
|
111542
|
+
this.part.motif.on("pointerdown", (_, e) => this.pressed(e));
|
|
111543
|
+
this.draw();
|
|
111544
|
+
}
|
|
111545
|
+
/** Makes its content and lays it out: the first time it comes into view, or at once in a diagram that shows every node. */
|
|
111546
|
+
enter() {
|
|
111547
|
+
if (this.entered) return;
|
|
111548
|
+
this.entered = true;
|
|
111549
|
+
const tell = (what) => (_, e) => {
|
|
111550
|
+
if (!this.fromHandle(e)) this.host.told(what, this, e);
|
|
111551
|
+
};
|
|
111552
|
+
this.part.motif.on("click", tell("click"));
|
|
111553
|
+
this.part.motif.on("dblclick", tell("dblclick"));
|
|
111554
|
+
this.part.motif.on("contextmenu", tell("contextmenu"));
|
|
111555
|
+
this.part.motif.on("pointerenter", tell("enter"));
|
|
111556
|
+
this.part.motif.on("pointerleave", tell("leave"));
|
|
111557
|
+
onLayout(this.part, "size", (size) => {
|
|
111558
|
+
if (!size.width && !size.height) return;
|
|
111559
|
+
this.size = size;
|
|
111560
|
+
this.host.sized(this);
|
|
111561
|
+
this.readAnchors();
|
|
111761
111562
|
});
|
|
111762
|
-
this.
|
|
111763
|
-
|
|
111764
|
-
|
|
111563
|
+
this.draw();
|
|
111564
|
+
}
|
|
111565
|
+
/** Puts it on the page or takes it off, its content and state kept. */
|
|
111566
|
+
setLive(on) {
|
|
111567
|
+
this.live = on;
|
|
111568
|
+
kept$2(this.part, on && !this.hidden);
|
|
111569
|
+
}
|
|
111570
|
+
/** Its ports: the node's own, its kind's, or one in the middle of each side. */
|
|
111571
|
+
get ports() {
|
|
111572
|
+
return this.portList;
|
|
111573
|
+
}
|
|
111574
|
+
/** Whether the node or its kind names ports of its own. */
|
|
111575
|
+
get hasOwnPorts() {
|
|
111576
|
+
return !!(this.node.ports ?? this.kind?.ports);
|
|
111577
|
+
}
|
|
111578
|
+
/** Every port on each of its sides, where it stands now. */
|
|
111579
|
+
get places() {
|
|
111580
|
+
const rect = this.rect;
|
|
111581
|
+
const places = [];
|
|
111582
|
+
for (const port of this.portList) for (const side of sidesOf(port)) places.push({
|
|
111583
|
+
port,
|
|
111584
|
+
side,
|
|
111585
|
+
point: portPoint(rect, side, this.offsetOf(port, side))
|
|
111765
111586
|
});
|
|
111587
|
+
return places;
|
|
111766
111588
|
}
|
|
111767
|
-
/**
|
|
111768
|
-
|
|
111769
|
-
const
|
|
111770
|
-
|
|
111771
|
-
this.
|
|
111772
|
-
|
|
111773
|
-
|
|
111774
|
-
|
|
111775
|
-
|
|
111776
|
-
|
|
111777
|
-
|
|
111778
|
-
|
|
111779
|
-
|
|
111780
|
-
|
|
111781
|
-
|
|
111782
|
-
|
|
111783
|
-
}
|
|
111784
|
-
if (this.region) view.setLive(false);
|
|
111785
|
-
this.views.set(edge.id, view);
|
|
111786
|
-
}
|
|
111787
|
-
view.edge = edge;
|
|
111788
|
-
order.push(view);
|
|
111789
|
-
for (const id of [edge.source, edge.target]) {
|
|
111790
|
-
let lines = this.atNode.get(id);
|
|
111791
|
-
if (!lines) this.atNode.set(id, lines = /* @__PURE__ */ new Set());
|
|
111792
|
-
lines.add(view);
|
|
111589
|
+
/** Where a port stands: on the one of its sides nearest `toward`; `null` for a port it does not have. */
|
|
111590
|
+
placeOf(id, toward) {
|
|
111591
|
+
const port = this.port(id);
|
|
111592
|
+
if (!port) return null;
|
|
111593
|
+
const rect = this.rect;
|
|
111594
|
+
let best = null;
|
|
111595
|
+
let nearest = Infinity;
|
|
111596
|
+
for (const side of sidesOf(port)) {
|
|
111597
|
+
const point = portPoint(rect, side, this.offsetOf(port, side));
|
|
111598
|
+
const d = Math.hypot(point.x - toward.x, point.y - toward.y);
|
|
111599
|
+
if (d < nearest) {
|
|
111600
|
+
nearest = d;
|
|
111601
|
+
best = {
|
|
111602
|
+
port,
|
|
111603
|
+
side,
|
|
111604
|
+
point
|
|
111605
|
+
};
|
|
111793
111606
|
}
|
|
111794
|
-
this.dirty.add(view);
|
|
111795
111607
|
}
|
|
111796
|
-
|
|
111797
|
-
if (seen.has(id)) continue;
|
|
111798
|
-
this.views.delete(id);
|
|
111799
|
-
this.goingAround.delete(view);
|
|
111800
|
-
this.plain.delete(view);
|
|
111801
|
-
this.dirty.delete(view);
|
|
111802
|
-
this.selected.delete(id);
|
|
111803
|
-
view.remove();
|
|
111804
|
-
}
|
|
111805
|
-
this.order(order);
|
|
111806
|
-
this.host.askDraw();
|
|
111608
|
+
return best;
|
|
111807
111609
|
}
|
|
111808
|
-
/**
|
|
111809
|
-
|
|
111810
|
-
this.
|
|
111811
|
-
|
|
111812
|
-
|
|
111813
|
-
|
|
111610
|
+
/** How far along a side a port stands: beside the part its content anchors it to, else at its own offset. */
|
|
111611
|
+
offsetOf(port, side) {
|
|
111612
|
+
const at = this.offsets.get(port.id);
|
|
111613
|
+
if (at) return side === "left" || side === "right" ? at.down : at.across;
|
|
111614
|
+
return port.offset ?? .5;
|
|
111615
|
+
}
|
|
111616
|
+
/** Whether it holds other nodes. */
|
|
111617
|
+
get isGroup() {
|
|
111618
|
+
return !!this.kind?.group;
|
|
111619
|
+
}
|
|
111620
|
+
/** Whether it collapses to its header: a group, or a node of a kind that says so. */
|
|
111621
|
+
get isCollapsible() {
|
|
111622
|
+
return !!(this.kind?.group || this.kind?.collapsible);
|
|
111623
|
+
}
|
|
111624
|
+
/** Whether the user may resize it (a collapsed node not, until it opens), and the smallest size a resize leaves. */
|
|
111625
|
+
get isResizable() {
|
|
111626
|
+
if (this.isCollapsible && this.node.collapsed) return false;
|
|
111627
|
+
return this.node.resizable ?? this.kind?.resizable ?? false;
|
|
111628
|
+
}
|
|
111629
|
+
get minSize() {
|
|
111630
|
+
return {
|
|
111631
|
+
width: this.kind?.minWidth ?? 40,
|
|
111632
|
+
height: this.kind?.minHeight ?? 24
|
|
111633
|
+
};
|
|
111634
|
+
}
|
|
111635
|
+
port(id) {
|
|
111636
|
+
return id === void 0 ? null : this.ports.find((p) => p.id === id) ?? null;
|
|
111637
|
+
}
|
|
111638
|
+
/** Marks a port as the end a connection being drawn would take, or would be refused at; none for `null`. */
|
|
111639
|
+
markPort(id, state) {
|
|
111640
|
+
for (const { port, part: p } of this.portParts.values()) {
|
|
111641
|
+
mark(p, "data-target", port === id && state === "target");
|
|
111642
|
+
mark(p, "data-refused", port === id && state === "refused");
|
|
111814
111643
|
}
|
|
111815
|
-
|
|
111644
|
+
}
|
|
111645
|
+
/** Marks the ports a connection being drawn may end at; none for `null`. */
|
|
111646
|
+
markAvailable(ids) {
|
|
111647
|
+
for (const { port, part: p } of this.portParts.values()) mark(p, "data-available", !!ids?.has(port));
|
|
111648
|
+
}
|
|
111649
|
+
markSelected(on) {
|
|
111650
|
+
mark(this.part, "data-selected", on);
|
|
111651
|
+
}
|
|
111652
|
+
markMovable(on) {
|
|
111653
|
+
mark(this.part, "data-movable", on);
|
|
111654
|
+
}
|
|
111655
|
+
markDragging(on) {
|
|
111656
|
+
mark(this.part, "data-dragging", on);
|
|
111657
|
+
}
|
|
111658
|
+
/** The node the keys are on. */
|
|
111659
|
+
markActive(on) {
|
|
111660
|
+
mark(this.part, "data-active", on);
|
|
111661
|
+
}
|
|
111662
|
+
/** A group under it is collapsed: it leaves the surface, in its place. */
|
|
111663
|
+
markHidden(on) {
|
|
111664
|
+
this.hidden = on;
|
|
111665
|
+
if (this.entered) kept$2(this.part, this.live && !on);
|
|
111666
|
+
}
|
|
111667
|
+
/** A group that will take the node if it is dropped now. */
|
|
111668
|
+
markDropTarget(on) {
|
|
111669
|
+
mark(this.part, "data-drop-target", on);
|
|
111670
|
+
}
|
|
111671
|
+
/** What a screen reader calls it: the name its kind's content gives, else its text, else its `id`. */
|
|
111672
|
+
get name() {
|
|
111673
|
+
return (this.naming ? untracked(this.naming) : this.node.text) || this.node.id;
|
|
111674
|
+
}
|
|
111675
|
+
/** Writes what the node says now; what did not change is not written again. */
|
|
111676
|
+
draw() {
|
|
111677
|
+
const node = this.node;
|
|
111678
|
+
const kind = this.host.kindOf(node);
|
|
111679
|
+
this.kind = kind;
|
|
111680
|
+
this.portList = node.ports ?? (typeof kind.ports === "function" ? kind.ports(node) : kind.ports) ?? SIDE_PORTS;
|
|
111681
|
+
if (!this.entered) return;
|
|
111682
|
+
if (kind !== this.made) this.build(kind);
|
|
111683
|
+
put(this.part, "data-id", node.id);
|
|
111684
|
+
put(this.part, "data-kind", node.kind ?? null);
|
|
111685
|
+
this.drawPlace();
|
|
111686
|
+
this.drawSize();
|
|
111687
|
+
if (kind.content) kind.update?.(this.context);
|
|
111688
|
+
else if (this.label) text$1(this.label, node.text ?? "");
|
|
111689
|
+
if (!this.naming) put(this.part, "aria-label", this.name);
|
|
111690
|
+
put(this.part, "aria-roledescription", uiLocale.strings.diagramNode);
|
|
111691
|
+
mark(this.part, "data-no-connect", node.connectable === false);
|
|
111692
|
+
mark(this.part, "data-group", !!kind.group);
|
|
111693
|
+
mark(this.part, "data-collapsed", this.isCollapsible && !!node.collapsed);
|
|
111694
|
+
mark(this.part, "data-resizable", this.isResizable);
|
|
111695
|
+
this.drawLook(kind);
|
|
111696
|
+
this.drawStatus();
|
|
111697
|
+
this.drawPorts();
|
|
111698
|
+
this.drawResizers();
|
|
111699
|
+
this.readAnchors();
|
|
111700
|
+
}
|
|
111701
|
+
/** Moves the node to its place now, while it is dragged: only its place is written. */
|
|
111702
|
+
drawPlace() {
|
|
111703
|
+
css(this.part, "transform", `translate(${this.node.x}px, ${this.node.y}px)`);
|
|
111816
111704
|
}
|
|
111817
111705
|
/**
|
|
111818
|
-
*
|
|
111819
|
-
*
|
|
111706
|
+
* Writes the size the node gives, while it is resized too; without one it takes the size of its content, no smaller
|
|
111707
|
+
* than its kind allows. A collapsed group keeps its width and takes the height of its header.
|
|
111820
111708
|
*/
|
|
111821
|
-
|
|
111822
|
-
this.
|
|
111823
|
-
const
|
|
111824
|
-
|
|
111825
|
-
|
|
111826
|
-
|
|
111827
|
-
|
|
111828
|
-
|
|
111829
|
-
|
|
111830
|
-
|
|
111831
|
-
|
|
111832
|
-
for (const line of this.goingAround) {
|
|
111833
|
-
if (lines.has(line) || !line.corners.length) continue;
|
|
111834
|
-
const box = boundsOf(line.corners, this.look.gap);
|
|
111835
|
-
if (overlaps$2(box, now) || was && overlaps$2(box, was)) lines.add(line);
|
|
111836
|
-
}
|
|
111837
|
-
}
|
|
111838
|
-
if (!lines.size) return;
|
|
111839
|
-
for (const view of lines) this.dirty.add(view);
|
|
111840
|
-
this.host.askDraw();
|
|
111709
|
+
drawSize() {
|
|
111710
|
+
const given = this.given;
|
|
111711
|
+
const kind = this.kind;
|
|
111712
|
+
css(this.part, "width", given.width !== null ? `${given.width}px` : "");
|
|
111713
|
+
css(this.part, "max-width", given.width !== null ? "none" : "");
|
|
111714
|
+
css(this.part, "height", given.height !== null ? `${given.height}px` : "");
|
|
111715
|
+
const min = this.minSize;
|
|
111716
|
+
const minWidth = kind?.minWidth ?? (this.isResizable ? min.width : given.width !== null ? 0 : null);
|
|
111717
|
+
const minHeight = kind?.minHeight ?? (this.isResizable ? min.height : given.height !== null ? 0 : null);
|
|
111718
|
+
css(this.part, "min-width", this.folded("horizontal") ? "0" : minWidth !== null ? `${minWidth}px` : "");
|
|
111719
|
+
css(this.part, "min-height", this.folded("vertical") ? "0" : minHeight !== null ? `${minHeight}px` : "");
|
|
111841
111720
|
}
|
|
111842
|
-
/** Whether
|
|
111843
|
-
|
|
111844
|
-
|
|
111845
|
-
|
|
111721
|
+
/** Whether it has a size to draw with: laid out, given, or likely (a node of a large diagram not seen yet). */
|
|
111722
|
+
get isSized() {
|
|
111723
|
+
return !this.hidden && (this.size.width > 0 || this.given.width !== null || this.host.estimate(this).width > 0);
|
|
111724
|
+
}
|
|
111725
|
+
/** Whether its size is known for sure: laid out, or both sides given. */
|
|
111726
|
+
get isMeasured() {
|
|
111727
|
+
const given = this.given;
|
|
111728
|
+
return !this.hidden && (this.size.width > 0 || given.width !== null && given.height !== null);
|
|
111846
111729
|
}
|
|
111847
111730
|
/**
|
|
111848
|
-
*
|
|
111849
|
-
*
|
|
111731
|
+
* Its place and size in the diagram's units: a side it gives as given (no smaller than its kind allows), which holds
|
|
111732
|
+
* at once while it is resized; else as laid out, or, not laid out yet in a large diagram, as it is likely to be.
|
|
111850
111733
|
*/
|
|
111851
|
-
|
|
111852
|
-
|
|
111853
|
-
|
|
111854
|
-
|
|
111855
|
-
|
|
111856
|
-
|
|
111857
|
-
|
|
111858
|
-
|
|
111859
|
-
|
|
111860
|
-
|
|
111861
|
-
|
|
111862
|
-
|
|
111863
|
-
/** The corners of every line drawn, for a sketch of the diagram. */
|
|
111864
|
-
sketches() {
|
|
111865
|
-
const out = [];
|
|
111866
|
-
for (const view of this.views.values()) if (view.ends && view.corners.length) out.push(view.corners);
|
|
111867
|
-
return out;
|
|
111734
|
+
get rect() {
|
|
111735
|
+
const node = this.node;
|
|
111736
|
+
const given = this.given;
|
|
111737
|
+
const size = this.size.width > 0 ? this.size : this.host.estimate(this);
|
|
111738
|
+
const width = given.width !== null ? Math.max(given.width, this.kind?.minWidth ?? 0) : size.width;
|
|
111739
|
+
const height = given.height !== null ? Math.max(given.height, this.kind?.minHeight ?? 0) : size.height;
|
|
111740
|
+
return {
|
|
111741
|
+
x: node.x,
|
|
111742
|
+
y: node.y,
|
|
111743
|
+
width,
|
|
111744
|
+
height
|
|
111745
|
+
};
|
|
111868
111746
|
}
|
|
111869
|
-
/**
|
|
111870
|
-
|
|
111871
|
-
const
|
|
111872
|
-
|
|
111873
|
-
|
|
111874
|
-
|
|
111747
|
+
/** The sides of its size it gives: a collapsed group takes one from its header. */
|
|
111748
|
+
get given() {
|
|
111749
|
+
const node = this.node;
|
|
111750
|
+
return {
|
|
111751
|
+
width: node.width != null && !this.folded("horizontal") ? node.width : null,
|
|
111752
|
+
height: node.height != null && !this.folded("vertical") ? node.height : null
|
|
111753
|
+
};
|
|
111875
111754
|
}
|
|
111876
|
-
/**
|
|
111877
|
-
|
|
111878
|
-
this.
|
|
111879
|
-
for (const view of this.views.values()) this.dirty.add(view);
|
|
111880
|
-
this.host.askDraw();
|
|
111755
|
+
/** Whether it is collapsed the way given: `'vertical'` to the height of its header, `'horizontal'` to its width. */
|
|
111756
|
+
folded(way) {
|
|
111757
|
+
return this.isCollapsible && !!this.node.collapsed && (this.kind?.collapse ?? "vertical") === way;
|
|
111881
111758
|
}
|
|
111882
|
-
/**
|
|
111883
|
-
|
|
111884
|
-
|
|
111885
|
-
for (const edge of this.host.edges()) {
|
|
111886
|
-
const picture = this.views.get(edge.id)?.picture;
|
|
111887
|
-
if (!picture) continue;
|
|
111888
|
-
if (nodes) {
|
|
111889
|
-
const source = this.host.shown(edge.source)?.node.id;
|
|
111890
|
-
const target = this.host.shown(edge.target)?.node.id;
|
|
111891
|
-
if (source === void 0 || target === void 0 || !nodes.has(source) || !nodes.has(target)) continue;
|
|
111892
|
-
}
|
|
111893
|
-
out.push(picture);
|
|
111894
|
-
}
|
|
111895
|
-
return out;
|
|
111759
|
+
/** Reads where the parts its ports stand beside are, with the window's next run. */
|
|
111760
|
+
readAnchors() {
|
|
111761
|
+
if (this.anchors.size || this.offsets.size) measure(this.part, this.anchorsRead, this.anchorsWritten);
|
|
111896
111762
|
}
|
|
111897
|
-
/**
|
|
111898
|
-
|
|
111899
|
-
this.
|
|
111900
|
-
this.
|
|
111901
|
-
|
|
111902
|
-
|
|
111903
|
-
|
|
111904
|
-
|
|
111905
|
-
|
|
111906
|
-
|
|
111907
|
-
|
|
111908
|
-
|
|
111909
|
-
|
|
111910
|
-
|
|
111911
|
-
|
|
111912
|
-
if (!ends) view.hide();
|
|
111913
|
-
else view.draw(ends.source.point, ends.source.side, ends.target.point, ends.target.side, view.edge.path ?? this.host.shape(), look, full ? around() : []);
|
|
111914
|
-
if (view.setLive(this.wanted(view))) made = true;
|
|
111763
|
+
/** Makes the content of a kind, in place of what the last one made. */
|
|
111764
|
+
build(kind) {
|
|
111765
|
+
clearParts(this.body);
|
|
111766
|
+
this.label = null;
|
|
111767
|
+
this.textHolder = null;
|
|
111768
|
+
this.handle = null;
|
|
111769
|
+
this.anchors.clear();
|
|
111770
|
+
this.offsets = /* @__PURE__ */ new Map();
|
|
111771
|
+
this.stopNaming?.();
|
|
111772
|
+
this.stopNaming = null;
|
|
111773
|
+
this.naming = null;
|
|
111774
|
+
this.made = kind;
|
|
111775
|
+
if (!kind.content) {
|
|
111776
|
+
this.label = part(this.body, "div", "mx-diagram__node-text");
|
|
111777
|
+
return;
|
|
111915
111778
|
}
|
|
111916
|
-
this.
|
|
111917
|
-
if (made) this.
|
|
111918
|
-
this.
|
|
111919
|
-
if (this.session) this.drawLine();
|
|
111779
|
+
const made = kind.content(this.context);
|
|
111780
|
+
if (made instanceof ComponentBase) this.body.controls.add(made);
|
|
111781
|
+
else if (made !== void 0 && made !== null && made !== "") text$1(this.body, String(made));
|
|
111920
111782
|
}
|
|
111921
111783
|
/**
|
|
111922
|
-
*
|
|
111923
|
-
*
|
|
111784
|
+
* A press on the node: a resize handle resizes, a port draws a connection, a control of the content keeps it, and
|
|
111785
|
+
* the rest drags the node (off a drag handle, it only selects).
|
|
111924
111786
|
*/
|
|
111925
|
-
|
|
111926
|
-
|
|
111927
|
-
const
|
|
111928
|
-
|
|
111929
|
-
|
|
111930
|
-
|
|
111931
|
-
if (this.selected.has(id) && view?.ends && view.edge.reconnectable !== false && this.host.connectable()) continue;
|
|
111932
|
-
removePart(pair.source);
|
|
111933
|
-
removePart(pair.target);
|
|
111934
|
-
this.handles.delete(id);
|
|
111787
|
+
pressed(e) {
|
|
111788
|
+
if (this.editor?.motif.isEventFrom(e)) return;
|
|
111789
|
+
for (const [side, p] of this.resizers) {
|
|
111790
|
+
if (!p.motif.isEventFrom(e)) continue;
|
|
111791
|
+
this.host.resizePressed(this, side, e);
|
|
111792
|
+
return;
|
|
111935
111793
|
}
|
|
111936
|
-
for (const
|
|
111937
|
-
|
|
111938
|
-
|
|
111939
|
-
|
|
111940
|
-
if (!pair) {
|
|
111941
|
-
pair = {
|
|
111942
|
-
source: this.handle(view, "source"),
|
|
111943
|
-
target: this.handle(view, "target")
|
|
111944
|
-
};
|
|
111945
|
-
this.handles.set(id, pair);
|
|
111946
|
-
}
|
|
111947
|
-
for (const end of ["source", "target"]) {
|
|
111948
|
-
const at = view.ends[end];
|
|
111949
|
-
css(pair[end], "transform", `translate(${round(at.x)}px, ${round(at.y)}px) scale(${round(1 / zoom)}) translate(-50%, -50%)`);
|
|
111950
|
-
}
|
|
111794
|
+
for (const { port, part: p } of this.portParts.values()) {
|
|
111795
|
+
if (!p.motif.isEventFrom(e)) continue;
|
|
111796
|
+
this.host.pressed(this, this.port(port), e, false);
|
|
111797
|
+
return;
|
|
111951
111798
|
}
|
|
111799
|
+
if (this.fromControl(this.body, e)) return;
|
|
111800
|
+
this.host.pressed(this, null, e, !this.handle || this.handle.motif.isEventFrom(e));
|
|
111952
111801
|
}
|
|
111953
|
-
|
|
111954
|
-
|
|
111955
|
-
|
|
111956
|
-
|
|
111957
|
-
|
|
111958
|
-
|
|
111959
|
-
handle.motif.on("pointerdown", (_, e) => {
|
|
111960
|
-
if (this.session || e.button !== 0) return;
|
|
111961
|
-
this.grabEnd(view, end, e);
|
|
111962
|
-
});
|
|
111963
|
-
return handle;
|
|
111802
|
+
/** Whether an event comes from a port, a resize handle or the editor of its text: none of them is the node's own. */
|
|
111803
|
+
fromHandle(e) {
|
|
111804
|
+
if (this.editor?.motif.isEventFrom(e)) return true;
|
|
111805
|
+
for (const p of this.resizers.values()) if (p.motif.isEventFrom(e)) return true;
|
|
111806
|
+
for (const { part: p } of this.portParts.values()) if (p.motif.isEventFrom(e)) return true;
|
|
111807
|
+
return false;
|
|
111964
111808
|
}
|
|
111965
|
-
/**
|
|
111966
|
-
|
|
111967
|
-
return this.
|
|
111809
|
+
/** Whether an event came from the part that shows its text: anywhere on a node of a text, off its ports and handles. */
|
|
111810
|
+
isTextEvent(e) {
|
|
111811
|
+
if (!this.made?.content) return !this.fromHandle(e);
|
|
111812
|
+
return !!this.textHolder?.motif.isEventFrom(e);
|
|
111968
111813
|
}
|
|
111969
|
-
/** The
|
|
111970
|
-
|
|
111971
|
-
return this.
|
|
111814
|
+
/** The part its text is edited over: the one that shows it, else its content. */
|
|
111815
|
+
get textPlace() {
|
|
111816
|
+
return this.textHolder ?? this.label ?? this.body;
|
|
111817
|
+
}
|
|
111818
|
+
/** Whether its text is being edited in place. */
|
|
111819
|
+
get isEditing() {
|
|
111820
|
+
return !!this.editor;
|
|
111972
111821
|
}
|
|
111973
111822
|
/**
|
|
111974
|
-
*
|
|
111975
|
-
*
|
|
111823
|
+
* Puts the editor of its text over the part that shows the text, as wide as it and no narrower than the editor's
|
|
111824
|
+
* own smallest; `null` takes it away. The editor is placed with the window's next measuring round, when the node is
|
|
111825
|
+
* laid out, and moves and zooms with the node.
|
|
111976
111826
|
*/
|
|
111977
|
-
|
|
111978
|
-
|
|
111979
|
-
|
|
111980
|
-
|
|
111981
|
-
|
|
111982
|
-
|
|
111983
|
-
|
|
111984
|
-
|
|
111985
|
-
|
|
111986
|
-
|
|
111987
|
-
|
|
111988
|
-
|
|
111989
|
-
|
|
111990
|
-
|
|
111991
|
-
|
|
111992
|
-
});
|
|
111993
|
-
|
|
111994
|
-
|
|
111827
|
+
holdEditor(editor) {
|
|
111828
|
+
if (this.editor === editor) return;
|
|
111829
|
+
removePart(this.editor);
|
|
111830
|
+
this.editor = editor;
|
|
111831
|
+
mark(this.part, "data-editing", !!editor);
|
|
111832
|
+
if (!editor) return;
|
|
111833
|
+
this.part.controls.add(editor);
|
|
111834
|
+
const place = this.textPlace;
|
|
111835
|
+
measure(this.part, () => ({
|
|
111836
|
+
box: rectOf(this.part),
|
|
111837
|
+
at: rectOf(place)
|
|
111838
|
+
}), ({ box, at }) => {
|
|
111839
|
+
if (this.editor !== editor || box.width <= 0 || this.size.width <= 0) return;
|
|
111840
|
+
const zoom = box.width / this.size.width;
|
|
111841
|
+
css(editor, "left", `${(at.left - box.left) / zoom}px`);
|
|
111842
|
+
css(editor, "top", `${(at.top - box.top + at.height / 2) / zoom}px`);
|
|
111843
|
+
css(editor, "width", `${at.width / zoom}px`);
|
|
111844
|
+
});
|
|
111995
111845
|
}
|
|
111996
111846
|
/**
|
|
111997
|
-
*
|
|
111998
|
-
*
|
|
111847
|
+
* Whether an event comes from a control inside `from`: a part that takes focus, a control of the kit whose focus is a
|
|
111848
|
+
* part of its own (a field), or one that is off (a button that is off keeps the press too). A layout of the kit, such
|
|
111849
|
+
* as a stack, is looked into.
|
|
111850
|
+
*/
|
|
111851
|
+
fromControl(from, e) {
|
|
111852
|
+
for (const child of from.controls.items) {
|
|
111853
|
+
if (!child.motif.isEventFrom(e)) continue;
|
|
111854
|
+
if (canTakeFocus(child)) return true;
|
|
111855
|
+
if (child instanceof Control && (child.focusPart !== null && child.focusPart !== child || !child.isEnabled)) return true;
|
|
111856
|
+
return this.fromControl(child, e);
|
|
111857
|
+
}
|
|
111858
|
+
return false;
|
|
111859
|
+
}
|
|
111860
|
+
/** The app's and the kind's classes, and the app's style properties; those taken away since the last draw come off. */
|
|
111861
|
+
drawLook(kind) {
|
|
111862
|
+
const classes = `${kind.cssClass ?? ""} ${this.node.cssClass ?? ""}`.split(/\s+/).filter(Boolean);
|
|
111863
|
+
for (const name of this.drawnClasses) if (!classes.includes(name)) toggleClass(this.part, name, false);
|
|
111864
|
+
for (const name of classes) toggleClass(this.part, name, true);
|
|
111865
|
+
this.drawnClasses = classes;
|
|
111866
|
+
const style = this.node.style ?? {};
|
|
111867
|
+
for (const name of this.drawnStyle) if (!(name in style)) css(this.part, name, "");
|
|
111868
|
+
for (const [name, value] of Object.entries(style)) css(this.part, name, value);
|
|
111869
|
+
this.drawnStyle = Object.keys(style);
|
|
111870
|
+
}
|
|
111871
|
+
/** Its status: a mark in its corner with the status in its tip, and the same said with its name to a screen reader. */
|
|
111872
|
+
drawStatus() {
|
|
111873
|
+
const status = this.node.status;
|
|
111874
|
+
put(this.part, "data-status", status ?? null);
|
|
111875
|
+
if (!status) {
|
|
111876
|
+
removePart(this.statusMark);
|
|
111877
|
+
this.statusMark = null;
|
|
111878
|
+
put(this.part, "aria-description", null);
|
|
111879
|
+
return;
|
|
111880
|
+
}
|
|
111881
|
+
if (!this.statusMark) {
|
|
111882
|
+
this.statusMark = part(this.part, "span", "mx-glyph mx-diagram__status");
|
|
111883
|
+
put(this.statusMark, "aria-hidden", "true");
|
|
111884
|
+
}
|
|
111885
|
+
const said = statusWords(status, this.node.statusText);
|
|
111886
|
+
put(this.statusMark, "title", said);
|
|
111887
|
+
put(this.part, "aria-description", said);
|
|
111888
|
+
}
|
|
111889
|
+
/** A part for each port on each of its sides, matched by `id` and side, at its place there. */
|
|
111890
|
+
drawPorts() {
|
|
111891
|
+
const seen = /* @__PURE__ */ new Set();
|
|
111892
|
+
for (const port of this.portList) for (const side of sidesOf(port)) {
|
|
111893
|
+
const key = `${port.id}\n${side}`;
|
|
111894
|
+
seen.add(key);
|
|
111895
|
+
let entry = this.portParts.get(key);
|
|
111896
|
+
if (!entry) {
|
|
111897
|
+
const p = part(this.part, "div", "mx-diagram__port");
|
|
111898
|
+
p.attr.add({ "aria-hidden": "true" });
|
|
111899
|
+
entry = {
|
|
111900
|
+
port: port.id,
|
|
111901
|
+
side,
|
|
111902
|
+
part: p
|
|
111903
|
+
};
|
|
111904
|
+
this.portParts.set(key, entry);
|
|
111905
|
+
}
|
|
111906
|
+
put(entry.part, "data-port", port.id);
|
|
111907
|
+
put(entry.part, "data-side", side);
|
|
111908
|
+
put(entry.part, "data-direction", port.direction && port.direction !== "both" ? port.direction : null);
|
|
111909
|
+
put(entry.part, "title", port.label || null);
|
|
111910
|
+
css(entry.part, "--_at", `${this.offsetOf(port, side) * 100}%`);
|
|
111911
|
+
}
|
|
111912
|
+
for (const [key, entry] of this.portParts) {
|
|
111913
|
+
if (seen.has(key)) continue;
|
|
111914
|
+
this.portParts.delete(key);
|
|
111915
|
+
removePart(entry.part);
|
|
111916
|
+
}
|
|
111917
|
+
}
|
|
111918
|
+
/** The resize handles of a node the user may resize, at its sides and corners; shown while it is selected. */
|
|
111919
|
+
drawResizers() {
|
|
111920
|
+
if (!this.isResizable) {
|
|
111921
|
+
for (const p of this.resizers.values()) removePart(p);
|
|
111922
|
+
this.resizers.clear();
|
|
111923
|
+
return;
|
|
111924
|
+
}
|
|
111925
|
+
for (const side of RESIZE_SIDES) {
|
|
111926
|
+
if (this.resizers.has(side)) continue;
|
|
111927
|
+
const p = part(this.part, "div", "mx-diagram__resizer");
|
|
111928
|
+
p.attr.add({
|
|
111929
|
+
"aria-hidden": "true",
|
|
111930
|
+
"data-side": side
|
|
111931
|
+
});
|
|
111932
|
+
this.resizers.set(side, p);
|
|
111933
|
+
}
|
|
111934
|
+
}
|
|
111935
|
+
};
|
|
111936
|
+
//#endregion
|
|
111937
|
+
//#region src/components/diagram/DiagramEdgeView.ts
|
|
111938
|
+
/** How far a line's labels and marks may reach out of the box around its corners, in the diagram's units. */
|
|
111939
|
+
var LABEL_ROOM = 80;
|
|
111940
|
+
/**
|
|
111941
|
+
* A connection on the surface: its line, the wider line the pointer finds it by, the marks at its ends and its label.
|
|
111942
|
+
* Its way is worked out at every draw; its parts are made the first time it is shown, and leave the page while it is not
|
|
111943
|
+
* (a line out of view in a large diagram).
|
|
111944
|
+
*/
|
|
111945
|
+
var DiagramEdgeView = class {
|
|
111946
|
+
constructor(edges, labels, edge, told) {
|
|
111947
|
+
_defineProperty(this, "edges", void 0);
|
|
111948
|
+
_defineProperty(this, "labels", void 0);
|
|
111949
|
+
_defineProperty(this, "told", void 0);
|
|
111950
|
+
_defineProperty(this, "parts", null);
|
|
111951
|
+
_defineProperty(
|
|
111952
|
+
this,
|
|
111953
|
+
/** The tip of its status, while it has one. */
|
|
111954
|
+
"tip",
|
|
111955
|
+
null
|
|
111956
|
+
);
|
|
111957
|
+
_defineProperty(
|
|
111958
|
+
this,
|
|
111959
|
+
/** The line as last worked out, written to its parts while it is shown. */
|
|
111960
|
+
"drawn",
|
|
111961
|
+
null
|
|
111962
|
+
);
|
|
111963
|
+
_defineProperty(this, "selected", false);
|
|
111964
|
+
_defineProperty(this, "moving", false);
|
|
111965
|
+
_defineProperty(this, "label", null);
|
|
111966
|
+
_defineProperty(
|
|
111967
|
+
this,
|
|
111968
|
+
/** The texts at its ends. */
|
|
111969
|
+
"endLabels",
|
|
111970
|
+
{
|
|
111971
|
+
source: null,
|
|
111972
|
+
target: null
|
|
111973
|
+
}
|
|
111974
|
+
);
|
|
111975
|
+
_defineProperty(
|
|
111976
|
+
this,
|
|
111977
|
+
/** The app's classes and style properties written last, so those it takes away are taken off. */
|
|
111978
|
+
"drawnClasses",
|
|
111979
|
+
[]
|
|
111980
|
+
);
|
|
111981
|
+
_defineProperty(this, "drawnStyle", []);
|
|
111982
|
+
_defineProperty(this, "edge", void 0);
|
|
111983
|
+
_defineProperty(
|
|
111984
|
+
this,
|
|
111985
|
+
/** Where its ends stood when it was last drawn, on the nodes, with the sides they leave by; `null` while it is not drawn. */
|
|
111986
|
+
"ends",
|
|
111987
|
+
null
|
|
111988
|
+
);
|
|
111989
|
+
_defineProperty(
|
|
111990
|
+
this,
|
|
111991
|
+
/** The points the line ran through when it was last drawn: its ends and corners (a curve's own points), and the shape it was drawn with. */
|
|
111992
|
+
"corners",
|
|
111993
|
+
[]
|
|
111994
|
+
);
|
|
111995
|
+
_defineProperty(this, "shape", "curve");
|
|
111996
|
+
_defineProperty(
|
|
111997
|
+
this,
|
|
111998
|
+
/** Around the line, its marks and its labels as last worked out, in the diagram's units; `null` while it is not drawn. */
|
|
111999
|
+
"bounds",
|
|
112000
|
+
null
|
|
112001
|
+
);
|
|
112002
|
+
_defineProperty(
|
|
112003
|
+
this,
|
|
112004
|
+
/** Whether it is on the page: it lies in view, or the diagram shows every line. */
|
|
112005
|
+
"live",
|
|
112006
|
+
true
|
|
112007
|
+
);
|
|
112008
|
+
this.edge = edge;
|
|
112009
|
+
this.edges = edges;
|
|
112010
|
+
this.labels = labels;
|
|
112011
|
+
this.told = told;
|
|
112012
|
+
}
|
|
112013
|
+
/** The group of its parts; `null` until it is first shown. */
|
|
112014
|
+
get group() {
|
|
112015
|
+
return this.parts?.group ?? null;
|
|
112016
|
+
}
|
|
112017
|
+
/** Puts it on the page or takes it off: its parts are made the first time. Returns whether they were made now. */
|
|
112018
|
+
setLive(on) {
|
|
112019
|
+
if (this.live === on) return false;
|
|
112020
|
+
this.live = on;
|
|
112021
|
+
if (!on) {
|
|
112022
|
+
kept$2(this.parts?.group ?? null, false);
|
|
112023
|
+
for (const label of [
|
|
112024
|
+
this.label,
|
|
112025
|
+
this.endLabels.source,
|
|
112026
|
+
this.endLabels.target
|
|
112027
|
+
]) kept$2(label, false);
|
|
112028
|
+
return false;
|
|
112029
|
+
}
|
|
112030
|
+
const made = !this.parts && !!this.drawn;
|
|
112031
|
+
this.write();
|
|
112032
|
+
return made;
|
|
112033
|
+
}
|
|
112034
|
+
/**
|
|
112035
|
+
* Draws the line between two points on their nodes, each with the side it leaves by, through the connection's own
|
|
112036
|
+
* points; an orthogonal line goes around `obstacles`, the nodes.
|
|
112037
|
+
*/
|
|
112038
|
+
draw(source, sourceSide, target, targetSide, shape, look, obstacles) {
|
|
112039
|
+
const edge = this.edge;
|
|
112040
|
+
const sourceMarker = edge.sourceMarker ?? "none";
|
|
112041
|
+
const targetMarker = edge.targetMarker ?? "arrow";
|
|
112042
|
+
const route = routeOf(shape, source, sourceSide, target, targetSide, {
|
|
112043
|
+
source: markerInset(sourceMarker, look.marker),
|
|
112044
|
+
target: markerInset(targetMarker, look.marker)
|
|
112045
|
+
}, look, edge.points ?? [], obstacles);
|
|
112046
|
+
this.ends = {
|
|
112047
|
+
source,
|
|
112048
|
+
sourceSide,
|
|
112049
|
+
target,
|
|
112050
|
+
targetSide
|
|
112051
|
+
};
|
|
112052
|
+
this.corners = route.corners;
|
|
112053
|
+
this.shape = shape;
|
|
112054
|
+
this.drawn = {
|
|
112055
|
+
route,
|
|
112056
|
+
sourceMarker,
|
|
112057
|
+
targetMarker,
|
|
112058
|
+
look
|
|
112059
|
+
};
|
|
112060
|
+
const room = look.gap * 2 + look.marker * 2 + (edge.label || edge.sourceLabel || edge.targetLabel ? LABEL_ROOM : 0);
|
|
112061
|
+
this.bounds = boundsAround([
|
|
112062
|
+
source,
|
|
112063
|
+
target,
|
|
112064
|
+
...route.corners
|
|
112065
|
+
], room);
|
|
112066
|
+
if (this.live) this.write();
|
|
112067
|
+
}
|
|
112068
|
+
/** Writes the line as last worked out to its parts, made now if it has none. */
|
|
112069
|
+
write() {
|
|
112070
|
+
const drawn = this.drawn;
|
|
112071
|
+
const ends = this.ends;
|
|
112072
|
+
if (!drawn || !ends) return;
|
|
112073
|
+
const p = this.parts ??= this.make();
|
|
112074
|
+
const { route, sourceMarker, targetMarker, look } = drawn;
|
|
112075
|
+
const edge = this.edge;
|
|
112076
|
+
put(p.group, "data-id", edge.id);
|
|
112077
|
+
mark(p.group, "data-dashed", edge.dashed || edge.animated);
|
|
112078
|
+
mark(p.group, "data-animated", edge.animated);
|
|
112079
|
+
this.drawLook(p.group);
|
|
112080
|
+
this.drawStatus(p.group);
|
|
112081
|
+
kept$2(p.group, true);
|
|
112082
|
+
put(p.line, "d", route.d);
|
|
112083
|
+
put(p.hit, "d", route.d);
|
|
112084
|
+
this.drawMark(p.sourceMark, sourceMarker, ends.source, route.sourceBack, look.marker);
|
|
112085
|
+
this.drawMark(p.targetMark, targetMarker, ends.target, route.targetBack, look.marker);
|
|
112086
|
+
this.drawLabel(route.label);
|
|
112087
|
+
this.drawEndLabel("source", edge.sourceLabel, ends.source, ends.sourceSide, look.marker);
|
|
112088
|
+
this.drawEndLabel("target", edge.targetLabel, ends.target, ends.targetSide, look.marker);
|
|
112089
|
+
}
|
|
112090
|
+
make() {
|
|
112091
|
+
const group = svgComponent(this.edges, "g", "mx-diagram__edge");
|
|
112092
|
+
const parts = {
|
|
112093
|
+
group,
|
|
112094
|
+
hit: svgComponent(group, "path", "mx-diagram__edge-hit"),
|
|
112095
|
+
line: svgComponent(group, "path", "mx-diagram__edge-line"),
|
|
112096
|
+
sourceMark: svgComponent(group, "path", "mx-diagram__edge-marker"),
|
|
112097
|
+
targetMark: svgComponent(group, "path", "mx-diagram__edge-marker")
|
|
112098
|
+
};
|
|
112099
|
+
group.motif.on("pointerdown", (_, e) => this.told.pressed(this, e));
|
|
112100
|
+
group.motif.on("click", (_, e) => this.told.clicked(this, e));
|
|
112101
|
+
group.motif.on("dblclick", (_, e) => this.told.pointer("dblclick", this, e));
|
|
112102
|
+
group.motif.on("contextmenu", (_, e) => this.told.pointer("contextmenu", this, e));
|
|
112103
|
+
group.motif.on("pointerenter", (_, e) => this.told.pointer("enter", this, e));
|
|
112104
|
+
group.motif.on("pointerleave", (_, e) => this.told.pointer("leave", this, e));
|
|
112105
|
+
mark(group, "data-selected", this.selected);
|
|
112106
|
+
mark(group, "data-moving", this.moving);
|
|
112107
|
+
return parts;
|
|
112108
|
+
}
|
|
112109
|
+
/** Not drawn: one of its nodes is missing or not laid out yet. */
|
|
112110
|
+
hide() {
|
|
112111
|
+
this.ends = null;
|
|
112112
|
+
this.drawn = null;
|
|
112113
|
+
this.bounds = null;
|
|
112114
|
+
kept$2(this.parts?.group ?? null, false);
|
|
112115
|
+
kept$2(this.label, false);
|
|
112116
|
+
kept$2(this.endLabels.source, false);
|
|
112117
|
+
kept$2(this.endLabels.target, false);
|
|
112118
|
+
}
|
|
112119
|
+
/** What an image of the diagram draws of it: its line and marks, and its labels; `null` while it is not drawn or not on the page. */
|
|
112120
|
+
get picture() {
|
|
112121
|
+
const p = this.parts;
|
|
112122
|
+
if (!this.ends || !p || !this.live) return null;
|
|
112123
|
+
const labels = [];
|
|
112124
|
+
for (const label of [
|
|
112125
|
+
this.label,
|
|
112126
|
+
this.endLabels.source,
|
|
112127
|
+
this.endLabels.target
|
|
112128
|
+
]) if (label) labels.push(label);
|
|
112129
|
+
return {
|
|
112130
|
+
marks: [
|
|
112131
|
+
p.line,
|
|
112132
|
+
p.sourceMark,
|
|
112133
|
+
p.targetMark
|
|
112134
|
+
],
|
|
112135
|
+
labels
|
|
112136
|
+
};
|
|
112137
|
+
}
|
|
112138
|
+
/** Marks it while one of its ends is being moved. */
|
|
112139
|
+
markMoving(on) {
|
|
112140
|
+
this.moving = on;
|
|
112141
|
+
if (this.parts) mark(this.parts.group, "data-moving", on);
|
|
112142
|
+
}
|
|
112143
|
+
markSelected(on) {
|
|
112144
|
+
this.selected = on;
|
|
112145
|
+
if (this.parts) mark(this.parts.group, "data-selected", on);
|
|
112146
|
+
for (const label of [
|
|
112147
|
+
this.label,
|
|
112148
|
+
this.endLabels.source,
|
|
112149
|
+
this.endLabels.target
|
|
112150
|
+
]) if (label) mark(label, "data-selected", on);
|
|
112151
|
+
}
|
|
112152
|
+
/** The app's color, width, classes and style properties; those it took away since the last draw come off. */
|
|
112153
|
+
drawLook(group) {
|
|
112154
|
+
const edge = this.edge;
|
|
112155
|
+
css(group, "color", edge.color ?? "");
|
|
112156
|
+
css(group, "--_diagram-edge-width", edge.width != null ? `${edge.width}px` : "");
|
|
112157
|
+
const classes = (edge.cssClass ?? "").split(/\s+/).filter(Boolean);
|
|
112158
|
+
for (const name of this.drawnClasses) if (!classes.includes(name)) toggleClass(group, name, false);
|
|
112159
|
+
for (const name of classes) toggleClass(group, name, true);
|
|
112160
|
+
this.drawnClasses = classes;
|
|
112161
|
+
const style = edge.style ?? {};
|
|
112162
|
+
for (const name of this.drawnStyle) if (!(name in style)) css(group, name, "");
|
|
112163
|
+
for (const [name, value] of Object.entries(style)) css(group, name, value);
|
|
112164
|
+
this.drawnStyle = Object.keys(style);
|
|
112165
|
+
}
|
|
112166
|
+
/** Writes its status again, as `setEdgeStatus` changed it: nothing else of the line changes. */
|
|
112167
|
+
drawState() {
|
|
112168
|
+
if (this.parts) this.drawStatus(this.parts.group);
|
|
112169
|
+
}
|
|
112170
|
+
/** Its status: the look's color of it on the line and its marks, and the status in the line's tip. */
|
|
112171
|
+
drawStatus(group) {
|
|
112172
|
+
const status = this.edge.status;
|
|
112173
|
+
put(group, "data-status", status ?? null);
|
|
112174
|
+
if (!status) {
|
|
112175
|
+
removePart(this.tip);
|
|
112176
|
+
this.tip = null;
|
|
112177
|
+
return;
|
|
112178
|
+
}
|
|
112179
|
+
this.tip ??= svgComponent(group, "title", "mx-diagram__edge-tip");
|
|
112180
|
+
text$1(this.tip, statusWords(status, this.edge.statusText));
|
|
112181
|
+
}
|
|
112182
|
+
remove() {
|
|
112183
|
+
removePart(this.label);
|
|
112184
|
+
removePart(this.endLabels.source);
|
|
112185
|
+
removePart(this.endLabels.target);
|
|
112186
|
+
removePart(this.parts?.group ?? null);
|
|
112187
|
+
this.parts = null;
|
|
112188
|
+
}
|
|
112189
|
+
drawMark(markPart, marker, tip, back, size) {
|
|
112190
|
+
put(markPart, "data-shape", marker === "none" ? null : marker);
|
|
112191
|
+
put(markPart, "d", markerPath(marker, tip, back, size) || null);
|
|
112192
|
+
}
|
|
112193
|
+
drawLabel(at) {
|
|
112194
|
+
const value = this.edge.label ?? "";
|
|
112195
|
+
if (!value) {
|
|
112196
|
+
removePart(this.label);
|
|
112197
|
+
this.label = null;
|
|
112198
|
+
return;
|
|
112199
|
+
}
|
|
112200
|
+
if (!this.label) {
|
|
112201
|
+
this.label = part(this.labels, "div", "mx-diagram__edge-label");
|
|
112202
|
+
mark(this.label, "data-selected", this.selected);
|
|
112203
|
+
}
|
|
112204
|
+
text$1(this.label, value);
|
|
112205
|
+
put(this.label, "data-edge", this.edge.id);
|
|
112206
|
+
kept$2(this.label, true);
|
|
112207
|
+
css(this.label, "transform", `translate(${round$1(at.x)}px, ${round$1(at.y)}px) translate(-50%, -50%)`);
|
|
112208
|
+
}
|
|
112209
|
+
/**
|
|
112210
|
+
* The text at an end: by the node, on the side of the line away from its mark's toes; above a line that leaves by a
|
|
112211
|
+
* side, after one that leaves by the top or the bottom.
|
|
112212
|
+
*/
|
|
112213
|
+
drawEndLabel(end, value, tip, side, size) {
|
|
112214
|
+
let label = this.endLabels[end];
|
|
112215
|
+
if (!value) {
|
|
112216
|
+
removePart(label);
|
|
112217
|
+
this.endLabels[end] = null;
|
|
112218
|
+
return;
|
|
112219
|
+
}
|
|
112220
|
+
if (!label) {
|
|
112221
|
+
label = part(this.labels, "div", "mx-diagram__edge-end-label");
|
|
112222
|
+
put(label, "data-end", end);
|
|
112223
|
+
mark(label, "data-selected", this.selected);
|
|
112224
|
+
this.endLabels[end] = label;
|
|
112225
|
+
}
|
|
112226
|
+
text$1(label, value);
|
|
112227
|
+
put(label, "data-edge", this.edge.id);
|
|
112228
|
+
put(label, "data-side", side);
|
|
112229
|
+
kept$2(label, true);
|
|
112230
|
+
const out = size * .4;
|
|
112231
|
+
const aside = size * .5 + 2;
|
|
112232
|
+
const [x, y, shift] = {
|
|
112233
|
+
right: [
|
|
112234
|
+
tip.x + out,
|
|
112235
|
+
tip.y - aside,
|
|
112236
|
+
"0, -100%"
|
|
112237
|
+
],
|
|
112238
|
+
left: [
|
|
112239
|
+
tip.x - out,
|
|
112240
|
+
tip.y - aside,
|
|
112241
|
+
"-100%, -100%"
|
|
112242
|
+
],
|
|
112243
|
+
top: [
|
|
112244
|
+
tip.x + aside,
|
|
112245
|
+
tip.y - out,
|
|
112246
|
+
"0, -100%"
|
|
112247
|
+
],
|
|
112248
|
+
bottom: [
|
|
112249
|
+
tip.x + aside,
|
|
112250
|
+
tip.y + out,
|
|
112251
|
+
"0, 0"
|
|
112252
|
+
]
|
|
112253
|
+
}[side];
|
|
112254
|
+
css(label, "transform", `translate(${round$1(x)}px, ${round$1(y)}px) translate(${shift})`);
|
|
112255
|
+
}
|
|
112256
|
+
};
|
|
112257
|
+
/** The box around `points`, `margin` out of them. */
|
|
112258
|
+
function boundsAround(points, margin) {
|
|
112259
|
+
let left = Infinity;
|
|
112260
|
+
let top = Infinity;
|
|
112261
|
+
let right = -Infinity;
|
|
112262
|
+
let bottom = -Infinity;
|
|
112263
|
+
for (const p of points) {
|
|
112264
|
+
left = Math.min(left, p.x);
|
|
112265
|
+
top = Math.min(top, p.y);
|
|
112266
|
+
right = Math.max(right, p.x);
|
|
112267
|
+
bottom = Math.max(bottom, p.y);
|
|
112268
|
+
}
|
|
112269
|
+
return {
|
|
112270
|
+
x: left - margin,
|
|
112271
|
+
y: top - margin,
|
|
112272
|
+
width: right - left + margin * 2,
|
|
112273
|
+
height: bottom - top + margin * 2
|
|
112274
|
+
};
|
|
112275
|
+
}
|
|
112276
|
+
function round$1(value) {
|
|
112277
|
+
return Math.round(value * 100) / 100;
|
|
112278
|
+
}
|
|
112279
|
+
//#endregion
|
|
112280
|
+
//#region src/components/diagram/DiagramLinks.ts
|
|
112281
|
+
/** How far a press moves before it draws a connection and is not a click, in pixels. */
|
|
112282
|
+
var DRAG_FROM$2 = 3;
|
|
112283
|
+
/** The way into a node through each side, for the end of a line drawn to the pointer. */
|
|
112284
|
+
var FACING$1 = {
|
|
112285
|
+
top: "bottom",
|
|
112286
|
+
right: "left",
|
|
112287
|
+
bottom: "top",
|
|
112288
|
+
left: "right"
|
|
112289
|
+
};
|
|
112290
|
+
/** The way out of a node through each side. */
|
|
112291
|
+
var OUT = {
|
|
112292
|
+
top: {
|
|
112293
|
+
x: 0,
|
|
112294
|
+
y: -1
|
|
112295
|
+
},
|
|
112296
|
+
right: {
|
|
112297
|
+
x: 1,
|
|
112298
|
+
y: 0
|
|
112299
|
+
},
|
|
112300
|
+
bottom: {
|
|
112301
|
+
x: 0,
|
|
112302
|
+
y: 1
|
|
112303
|
+
},
|
|
112304
|
+
left: {
|
|
112305
|
+
x: -1,
|
|
112306
|
+
y: 0
|
|
112307
|
+
}
|
|
112308
|
+
};
|
|
112309
|
+
/** Whether a port starts connections (`'source'`) or ends them (`'target'`). */
|
|
112310
|
+
function serves(port, end) {
|
|
112311
|
+
return !port.direction || port.direction === "both" || port.direction === end;
|
|
112312
|
+
}
|
|
112313
|
+
/**
|
|
112314
|
+
* The connections of a diagram: a line for each, matched by `id`; only the lines of what changed are drawn again. A
|
|
112315
|
+
* drag from a port draws a new connection, and a drag of an end moves it, both under the diagram's rules.
|
|
112316
|
+
*/
|
|
112317
|
+
var DiagramLinks = class {
|
|
112318
|
+
constructor(surface, edgeLayer, labelLayer, handleLayer, host) {
|
|
112319
|
+
_defineProperty(this, "surface", void 0);
|
|
112320
|
+
_defineProperty(this, "edgeLayer", void 0);
|
|
112321
|
+
_defineProperty(this, "labelLayer", void 0);
|
|
112322
|
+
_defineProperty(this, "handleLayer", void 0);
|
|
112323
|
+
_defineProperty(this, "host", void 0);
|
|
112324
|
+
_defineProperty(this, "autoPan", void 0);
|
|
112325
|
+
_defineProperty(
|
|
112326
|
+
this,
|
|
112327
|
+
/** The handles that move, add and take away the points of the selected lines; the keys do the same through it. */
|
|
112328
|
+
"bends",
|
|
112329
|
+
void 0
|
|
112330
|
+
);
|
|
112331
|
+
_defineProperty(this, "views", /* @__PURE__ */ new Map());
|
|
112332
|
+
_defineProperty(
|
|
112333
|
+
this,
|
|
112334
|
+
/** What every line tells the diagram: one object for all the lines, however many. */
|
|
112335
|
+
"told",
|
|
112336
|
+
{
|
|
112337
|
+
pressed: (v, e) => this.edgePressed(v, e),
|
|
112338
|
+
clicked: (v, e) => this.host.edgeClicked(v.edge, e),
|
|
112339
|
+
pointer: (what, v, e) => this.host.edgeTold(what, v.edge, e)
|
|
112340
|
+
}
|
|
112341
|
+
);
|
|
112342
|
+
_defineProperty(
|
|
112343
|
+
this,
|
|
112344
|
+
/** The selected connections, by `id`, and the handles over their ends, which take an end to move it. */
|
|
112345
|
+
"selected",
|
|
112346
|
+
/* @__PURE__ */ new Set()
|
|
112347
|
+
);
|
|
112348
|
+
_defineProperty(this, "handles", /* @__PURE__ */ new Map());
|
|
112349
|
+
_defineProperty(
|
|
112350
|
+
this,
|
|
112351
|
+
/** The lines of each node, by its `id`. */
|
|
112352
|
+
"atNode",
|
|
112353
|
+
/* @__PURE__ */ new Map()
|
|
112354
|
+
);
|
|
112355
|
+
_defineProperty(
|
|
112356
|
+
this,
|
|
112357
|
+
/** The lines to draw with the next frame. */
|
|
112358
|
+
"dirty",
|
|
112359
|
+
/* @__PURE__ */ new Set()
|
|
112360
|
+
);
|
|
112361
|
+
_defineProperty(
|
|
112362
|
+
this,
|
|
112363
|
+
/** Where each node stood when it last moved, for the lines that went around it there. */
|
|
112364
|
+
"lastRects",
|
|
112365
|
+
/* @__PURE__ */ new Map()
|
|
112366
|
+
);
|
|
112367
|
+
_defineProperty(
|
|
112368
|
+
this,
|
|
112369
|
+
/** The lines that go around the nodes, as last drawn: a node that moves looks at these alone. */
|
|
112370
|
+
"goingAround",
|
|
112371
|
+
/* @__PURE__ */ new Set()
|
|
112372
|
+
);
|
|
112373
|
+
_defineProperty(
|
|
112374
|
+
this,
|
|
112375
|
+
/** Lines that go around the nodes worked out as if nothing stood in their way while out of view: they find their way once shown. */
|
|
112376
|
+
"plain",
|
|
112377
|
+
/* @__PURE__ */ new Set()
|
|
112378
|
+
);
|
|
112379
|
+
_defineProperty(
|
|
112380
|
+
this,
|
|
112381
|
+
/**
|
|
112382
|
+
* Where lines are on the page, in a large diagram: those that reach into `inner`, and those on the page already that
|
|
112383
|
+
* reach into `outer`, the selected and the one whose end is moved; `null` puts every line on the page.
|
|
112384
|
+
*/
|
|
112385
|
+
"region",
|
|
112386
|
+
null
|
|
112387
|
+
);
|
|
112388
|
+
_defineProperty(
|
|
112389
|
+
this,
|
|
112390
|
+
/** The lines in the order of the connections, for the order of their parts. */
|
|
112391
|
+
"ordered",
|
|
112392
|
+
[]
|
|
112393
|
+
);
|
|
112394
|
+
_defineProperty(
|
|
112395
|
+
this,
|
|
112396
|
+
/** The line of the connection being drawn. */
|
|
112397
|
+
"line",
|
|
112398
|
+
void 0
|
|
112399
|
+
);
|
|
112400
|
+
_defineProperty(
|
|
112401
|
+
this,
|
|
112402
|
+
/** Presses a port or an end of a line took: the surface does not pan for them. */
|
|
112403
|
+
"taken",
|
|
112404
|
+
/* @__PURE__ */ new WeakSet()
|
|
112405
|
+
);
|
|
112406
|
+
_defineProperty(this, "look", {
|
|
112407
|
+
marker: 10,
|
|
112408
|
+
corner: 8,
|
|
112409
|
+
gap: 20
|
|
112410
|
+
});
|
|
112411
|
+
_defineProperty(
|
|
112412
|
+
this,
|
|
112413
|
+
/** How near a port the pointer must come for a connection to snap to it, in pixels. */
|
|
112414
|
+
"reach",
|
|
112415
|
+
20
|
|
112416
|
+
);
|
|
112417
|
+
_defineProperty(
|
|
112418
|
+
this,
|
|
112419
|
+
/**
|
|
112420
|
+
* The connection being drawn: the end that stays (a port, or a node whose side is chosen), which end of the
|
|
112421
|
+
* connection it is, where that end stands while an end of a line is moved (it does not move with the pointer), the
|
|
112422
|
+
* line moved, where the pointer is, and the ports the connection may end at.
|
|
112423
|
+
*/
|
|
112424
|
+
"session",
|
|
112425
|
+
null
|
|
112426
|
+
);
|
|
112427
|
+
_defineProperty(this, "stops", []);
|
|
112428
|
+
_defineProperty(
|
|
112429
|
+
this,
|
|
112430
|
+
/**
|
|
112431
|
+
* Set while nodes glide to their places: the lines that go around the nodes are drawn as if nothing stood in their
|
|
112432
|
+
* way, which is quick, and find their way again once the nodes stand still.
|
|
112433
|
+
*/
|
|
112434
|
+
"quick",
|
|
112435
|
+
false
|
|
112436
|
+
);
|
|
112437
|
+
this.surface = surface;
|
|
112438
|
+
this.edgeLayer = edgeLayer;
|
|
112439
|
+
this.labelLayer = labelLayer;
|
|
112440
|
+
this.handleLayer = handleLayer;
|
|
112441
|
+
this.host = host;
|
|
112442
|
+
this.line = svgComponent(edgeLayer, "path", "mx-diagram__connection");
|
|
112443
|
+
kept$2(this.line, false);
|
|
112444
|
+
this.bends = new DiagramBends(surface, handleLayer, {
|
|
112445
|
+
viewport: () => host.viewport(),
|
|
112446
|
+
room: () => host.room(),
|
|
112447
|
+
move: (viewport) => host.move(viewport),
|
|
112448
|
+
origin: () => host.origin(),
|
|
112449
|
+
snapStep: () => host.snapStep(),
|
|
112450
|
+
redraw: (view) => {
|
|
112451
|
+
this.dirty.add(view);
|
|
112452
|
+
host.askDraw();
|
|
112453
|
+
},
|
|
112454
|
+
reshaping: (e) => host.reshaping(e),
|
|
112455
|
+
reshaped: (e) => host.reshaped(e)
|
|
112456
|
+
});
|
|
112457
|
+
this.autoPan = new DiagramAutoPan(surface, host, () => {
|
|
112458
|
+
const s = this.session;
|
|
112459
|
+
if (s) this.follow(s.client.x, s.client.y);
|
|
112460
|
+
});
|
|
112461
|
+
}
|
|
112462
|
+
/** Matches the connections to their lines by `id`: a new one gets a line, a gone one loses it, all are drawn again. */
|
|
112463
|
+
edgesChanged() {
|
|
112464
|
+
const seen = /* @__PURE__ */ new Set();
|
|
112465
|
+
const order = [];
|
|
112466
|
+
this.atNode.clear();
|
|
112467
|
+
for (const edge of this.host.edges()) {
|
|
112468
|
+
if (edge?.id == null || seen.has(edge.id)) {
|
|
112469
|
+
errorHandler.reportSuppressed("Diagram", /* @__PURE__ */ new Error(`Every connection needs an id of its own; this one is left out: ${JSON.stringify(edge?.id)}`));
|
|
112470
|
+
continue;
|
|
112471
|
+
}
|
|
112472
|
+
seen.add(edge.id);
|
|
112473
|
+
let view = this.views.get(edge.id);
|
|
112474
|
+
if (!view) {
|
|
112475
|
+
view = new DiagramEdgeView(this.edgeLayer, this.labelLayer, edge, this.told);
|
|
112476
|
+
if (this.region) view.setLive(false);
|
|
112477
|
+
this.views.set(edge.id, view);
|
|
112478
|
+
}
|
|
112479
|
+
view.edge = edge;
|
|
112480
|
+
order.push(view);
|
|
112481
|
+
for (const id of [edge.source, edge.target]) {
|
|
112482
|
+
let lines = this.atNode.get(id);
|
|
112483
|
+
if (!lines) this.atNode.set(id, lines = /* @__PURE__ */ new Set());
|
|
112484
|
+
lines.add(view);
|
|
112485
|
+
}
|
|
112486
|
+
this.dirty.add(view);
|
|
112487
|
+
}
|
|
112488
|
+
for (const [id, view] of this.views) {
|
|
112489
|
+
if (seen.has(id)) continue;
|
|
112490
|
+
this.views.delete(id);
|
|
112491
|
+
this.goingAround.delete(view);
|
|
112492
|
+
this.plain.delete(view);
|
|
112493
|
+
this.dirty.delete(view);
|
|
112494
|
+
this.selected.delete(id);
|
|
112495
|
+
view.remove();
|
|
112496
|
+
}
|
|
112497
|
+
this.order(order);
|
|
112498
|
+
this.host.askDraw();
|
|
112499
|
+
}
|
|
112500
|
+
/** Marks the selected connections, by `id`: each shows a handle over its ends, drawn with the next frame. */
|
|
112501
|
+
select(ids) {
|
|
112502
|
+
this.selected.clear();
|
|
112503
|
+
for (const [id, view] of this.views) {
|
|
112504
|
+
view.markSelected(ids.has(id));
|
|
112505
|
+
if (ids.has(id)) this.selected.add(id);
|
|
112506
|
+
}
|
|
112507
|
+
this.host.askDraw();
|
|
112508
|
+
}
|
|
112509
|
+
/**
|
|
112510
|
+
* A node moved or changed its size: its lines are drawn again, those of the nodes hidden in it when it is a collapsed
|
|
112511
|
+
* group, and the lines that go around the nodes it moved into the way of, or out of it.
|
|
112512
|
+
*/
|
|
112513
|
+
nodeChanged(id) {
|
|
112514
|
+
this.host.nodesMoved();
|
|
112515
|
+
const lines = new Set(this.atNode.get(id) ?? []);
|
|
112516
|
+
const node = this.host.view(id);
|
|
112517
|
+
if (node?.isGroup && node.node.collapsed) {
|
|
112518
|
+
for (const line of this.views.values()) if (this.host.shown(line.edge.source) === node || this.host.shown(line.edge.target) === node) lines.add(line);
|
|
112519
|
+
}
|
|
112520
|
+
if (node?.isSized && !this.quick) {
|
|
112521
|
+
const now = node.rect;
|
|
112522
|
+
const was = this.lastRects.get(id);
|
|
112523
|
+
this.lastRects.set(id, now);
|
|
112524
|
+
for (const line of this.goingAround) {
|
|
112525
|
+
if (lines.has(line) || !line.corners.length) continue;
|
|
112526
|
+
const box = boundsOf(line.corners, this.look.gap);
|
|
112527
|
+
if (overlaps$2(box, now) || was && overlaps$2(box, was)) lines.add(line);
|
|
112528
|
+
}
|
|
112529
|
+
}
|
|
112530
|
+
if (!lines.size) return;
|
|
112531
|
+
for (const view of lines) this.dirty.add(view);
|
|
112532
|
+
this.host.askDraw();
|
|
112533
|
+
}
|
|
112534
|
+
/** Whether a line finds its own way around the nodes: orthogonal, with no points of its own. */
|
|
112535
|
+
goesAround(view) {
|
|
112536
|
+
const shape = view.edge.path ?? this.host.shape();
|
|
112537
|
+
return (shape === "orthogonal" || shape === "rounded-orthogonal") && !view.edge.points?.length;
|
|
112538
|
+
}
|
|
112539
|
+
/**
|
|
112540
|
+
* Puts on the page the lines in view, and takes off those far out of it (see `region`); `null` puts every line on it.
|
|
112541
|
+
* A line put on the page that was worked out plainly is drawn again with its way.
|
|
112542
|
+
*/
|
|
112543
|
+
cull(inner, outer) {
|
|
112544
|
+
this.region = inner && outer ? {
|
|
112545
|
+
inner,
|
|
112546
|
+
outer
|
|
112547
|
+
} : null;
|
|
112548
|
+
let made = false;
|
|
112549
|
+
for (const view of this.views.values()) {
|
|
112550
|
+
if (view.setLive(this.wanted(view))) made = true;
|
|
112551
|
+
if (view.live && this.plain.has(view)) this.dirty.add(view);
|
|
112552
|
+
}
|
|
112553
|
+
if (made) this.order(this.ordered);
|
|
112554
|
+
}
|
|
112555
|
+
/** The corners of every line drawn, for a sketch of the diagram. */
|
|
112556
|
+
sketches() {
|
|
112557
|
+
const out = [];
|
|
112558
|
+
for (const view of this.views.values()) if (view.ends && view.corners.length) out.push(view.corners);
|
|
112559
|
+
return out;
|
|
112560
|
+
}
|
|
112561
|
+
/** Whether a line is to be on the page: see `region`. */
|
|
112562
|
+
wanted(view) {
|
|
112563
|
+
const r = this.region;
|
|
112564
|
+
if (!r || this.selected.has(view.edge.id) || this.session?.moving === view) return true;
|
|
112565
|
+
const b = view.bounds;
|
|
112566
|
+
return !!b && (overlaps$2(b, r.inner) || view.live && overlaps$2(b, r.outer));
|
|
112567
|
+
}
|
|
112568
|
+
/** The nodes were read again: every line is drawn again (an unchanged one writes nothing). */
|
|
112569
|
+
nodesChanged() {
|
|
112570
|
+
this.host.nodesMoved();
|
|
112571
|
+
for (const view of this.views.values()) this.dirty.add(view);
|
|
112572
|
+
this.host.askDraw();
|
|
112573
|
+
}
|
|
112574
|
+
/** What an image of the diagram draws of the lines, in the order of the connections: those drawn between two of `nodes` (by `id`), or every one drawn. */
|
|
112575
|
+
pictures(nodes) {
|
|
112576
|
+
const out = [];
|
|
112577
|
+
for (const edge of this.host.edges()) {
|
|
112578
|
+
const picture = this.views.get(edge.id)?.picture;
|
|
112579
|
+
if (!picture) continue;
|
|
112580
|
+
if (nodes) {
|
|
112581
|
+
const source = this.host.shown(edge.source)?.node.id;
|
|
112582
|
+
const target = this.host.shown(edge.target)?.node.id;
|
|
112583
|
+
if (source === void 0 || target === void 0 || !nodes.has(source) || !nodes.has(target)) continue;
|
|
112584
|
+
}
|
|
112585
|
+
out.push(picture);
|
|
112586
|
+
}
|
|
112587
|
+
return out;
|
|
112588
|
+
}
|
|
112589
|
+
/** Draws the lines marked to draw, and the connection being drawn; called in a write of the diagram's frame. */
|
|
112590
|
+
draw(look, reach) {
|
|
112591
|
+
this.look = look;
|
|
112592
|
+
this.reach = reach;
|
|
112593
|
+
let obstacles = null;
|
|
112594
|
+
const around = () => obstacles ??= [...this.host.views()].filter((v) => v.isSized && !(v.isGroup && !v.node.collapsed)).map((v) => v.rect);
|
|
112595
|
+
let made = false;
|
|
112596
|
+
for (const view of this.dirty) {
|
|
112597
|
+
const ends = this.endsOf(view.edge);
|
|
112598
|
+
const goes = this.goesAround(view);
|
|
112599
|
+
if (goes) this.goingAround.add(view);
|
|
112600
|
+
else this.goingAround.delete(view);
|
|
112601
|
+
const full = goes && !this.quick && view.live;
|
|
112602
|
+
if (goes && !full && !this.quick) this.plain.add(view);
|
|
112603
|
+
else this.plain.delete(view);
|
|
112604
|
+
if (!ends) view.hide();
|
|
112605
|
+
else view.draw(ends.source.point, ends.source.side, ends.target.point, ends.target.side, view.edge.path ?? this.host.shape(), look, full ? around() : []);
|
|
112606
|
+
if (view.setLive(this.wanted(view))) made = true;
|
|
112607
|
+
}
|
|
112608
|
+
this.dirty.clear();
|
|
112609
|
+
if (made) this.order(this.ordered);
|
|
112610
|
+
this.drawHandles();
|
|
112611
|
+
if (this.session) this.drawLine();
|
|
112612
|
+
}
|
|
112613
|
+
/**
|
|
112614
|
+
* The handles over the ends of the selected connections, and over the points of their lines, a size on the screen at
|
|
112615
|
+
* any zoom; none for a line that may not move.
|
|
112616
|
+
*/
|
|
112617
|
+
drawHandles() {
|
|
112618
|
+
const zoom = this.host.viewport().zoom;
|
|
112619
|
+
const reshapable = [...this.selected].map((id) => this.views.get(id)).filter((v) => !!v?.ends && v.edge.reconnectable !== false && this.host.connectable());
|
|
112620
|
+
this.bends.draw(reshapable, zoom);
|
|
112621
|
+
for (const [id, pair] of this.handles) {
|
|
112622
|
+
const view = this.views.get(id);
|
|
112623
|
+
if (this.selected.has(id) && view?.ends && view.edge.reconnectable !== false && this.host.connectable()) continue;
|
|
112624
|
+
removePart(pair.source);
|
|
112625
|
+
removePart(pair.target);
|
|
112626
|
+
this.handles.delete(id);
|
|
112627
|
+
}
|
|
112628
|
+
for (const id of this.selected) {
|
|
112629
|
+
const view = this.views.get(id);
|
|
112630
|
+
if (!view?.ends || view.edge.reconnectable === false || !this.host.connectable()) continue;
|
|
112631
|
+
let pair = this.handles.get(id);
|
|
112632
|
+
if (!pair) {
|
|
112633
|
+
pair = {
|
|
112634
|
+
source: this.handle(view, "source"),
|
|
112635
|
+
target: this.handle(view, "target")
|
|
112636
|
+
};
|
|
112637
|
+
this.handles.set(id, pair);
|
|
112638
|
+
}
|
|
112639
|
+
for (const end of ["source", "target"]) {
|
|
112640
|
+
const at = view.ends[end];
|
|
112641
|
+
css(pair[end], "transform", `translate(${round(at.x)}px, ${round(at.y)}px) scale(${round(1 / zoom)}) translate(-50%, -50%)`);
|
|
112642
|
+
}
|
|
112643
|
+
}
|
|
112644
|
+
}
|
|
112645
|
+
handle(view, end) {
|
|
112646
|
+
const handle = part(this.handleLayer, "div", "mx-diagram__handle");
|
|
112647
|
+
handle.attr.add({
|
|
112648
|
+
"aria-hidden": "true",
|
|
112649
|
+
"data-end": end
|
|
112650
|
+
});
|
|
112651
|
+
handle.motif.on("pointerdown", (_, e) => {
|
|
112652
|
+
if (this.session || e.button !== 0) return;
|
|
112653
|
+
this.grabEnd(view, end, e);
|
|
112654
|
+
});
|
|
112655
|
+
return handle;
|
|
112656
|
+
}
|
|
112657
|
+
/** How many connections a node has. */
|
|
112658
|
+
countAt(id) {
|
|
112659
|
+
return this.atNode.get(id)?.size ?? 0;
|
|
112660
|
+
}
|
|
112661
|
+
/** The line of a connection, by `id`. */
|
|
112662
|
+
lineOf(id) {
|
|
112663
|
+
return this.views.get(id);
|
|
112664
|
+
}
|
|
112665
|
+
/**
|
|
112666
|
+
* The lines drawn at a node, those of the nodes hidden in it when it is a collapsed group too, clockwise from the top
|
|
112667
|
+
* by where their other ends are.
|
|
112668
|
+
*/
|
|
112669
|
+
linesAt(node) {
|
|
112670
|
+
const rect = node.rect;
|
|
112671
|
+
const x = rect.x + rect.width / 2;
|
|
112672
|
+
const y = rect.y + rect.height / 2;
|
|
112673
|
+
const found = [];
|
|
112674
|
+
for (const line of this.views.values()) {
|
|
112675
|
+
if (!line.ends) continue;
|
|
112676
|
+
const atSource = this.host.shown(line.edge.source) === node;
|
|
112677
|
+
const atTarget = this.host.shown(line.edge.target) === node;
|
|
112678
|
+
if (!atSource && !atTarget) continue;
|
|
112679
|
+
const other = atSource && !atTarget ? line.ends.target : line.ends.source;
|
|
112680
|
+
const angle = Math.atan2(other.x - x, y - other.y);
|
|
112681
|
+
found.push({
|
|
112682
|
+
line,
|
|
112683
|
+
angle: angle < 0 ? angle + Math.PI * 2 : angle
|
|
112684
|
+
});
|
|
112685
|
+
}
|
|
112686
|
+
return found.sort((a, b) => a.angle - b.angle).map((f) => f.line);
|
|
112687
|
+
}
|
|
112688
|
+
/**
|
|
112689
|
+
* The connection a line makes with its `end` taken to `node`, the other end kept: on the first of the node's own
|
|
112690
|
+
* ports that allows it, on no port at a node that names none; `null` when it is not allowed.
|
|
111999
112691
|
*/
|
|
112000
112692
|
movedEnd(line, end, node) {
|
|
112001
112693
|
const edge = line.edge;
|
|
@@ -112426,966 +113118,407 @@ var DiagramLinks = class {
|
|
|
112426
113118
|
const args = {
|
|
112427
113119
|
edge,
|
|
112428
113120
|
end,
|
|
112429
|
-
connection,
|
|
112430
|
-
cancel: false
|
|
112431
|
-
};
|
|
112432
|
-
this.host.reconnecting(args);
|
|
112433
|
-
if (args.cancel) return;
|
|
112434
|
-
if (end === "source") {
|
|
112435
|
-
edge.source = connection.source;
|
|
112436
|
-
edge.sourcePort = connection.sourcePort;
|
|
112437
|
-
} else {
|
|
112438
|
-
edge.target = connection.target;
|
|
112439
|
-
edge.targetPort = connection.targetPort;
|
|
112440
|
-
}
|
|
112441
|
-
this.edgesChanged();
|
|
112442
|
-
this.host.reconnected({
|
|
112443
|
-
edge,
|
|
112444
|
-
end,
|
|
112445
|
-
previous
|
|
112446
|
-
});
|
|
112447
|
-
}
|
|
112448
|
-
/** Whether a port takes no more connections: `moving` does not count. */
|
|
112449
|
-
full(node, port, moving) {
|
|
112450
|
-
if (!port || port.maxConnections === void 0) return false;
|
|
112451
|
-
let count = 0;
|
|
112452
|
-
for (const edge of this.host.edges()) {
|
|
112453
|
-
if (edge === moving) continue;
|
|
112454
|
-
if (edge.source === node && edge.sourcePort === port.id || edge.target === node && edge.targetPort === port.id) count++;
|
|
112455
|
-
}
|
|
112456
|
-
return count >= port.maxConnections;
|
|
112457
|
-
}
|
|
112458
|
-
newId() {
|
|
112459
|
-
const ids = new Set(this.host.edges().map((e) => e.id));
|
|
112460
|
-
let n = ids.size + 1;
|
|
112461
|
-
while (ids.has(`edge-${n}`)) n++;
|
|
112462
|
-
return `edge-${n}`;
|
|
112463
|
-
}
|
|
112464
|
-
/** The point of the diagram under a point of the page, the view as it is now. */
|
|
112465
|
-
pointAt(origin, client) {
|
|
112466
|
-
const v = this.host.viewport();
|
|
112467
|
-
return {
|
|
112468
|
-
x: (client.x - origin.x - v.x) / v.zoom,
|
|
112469
|
-
y: (client.y - origin.y - v.y) / v.zoom
|
|
112470
|
-
};
|
|
112471
|
-
}
|
|
112472
|
-
};
|
|
112473
|
-
function round(value) {
|
|
112474
|
-
return Math.round(value * 1e3) / 1e3;
|
|
112475
|
-
}
|
|
112476
|
-
/** The rectangle around points, `margin` wider on every side. */
|
|
112477
|
-
function boundsOf(points, margin) {
|
|
112478
|
-
const xs = points.map((p) => p.x);
|
|
112479
|
-
const ys = points.map((p) => p.y);
|
|
112480
|
-
const x = Math.min(...xs) - margin;
|
|
112481
|
-
const y = Math.min(...ys) - margin;
|
|
112482
|
-
return {
|
|
112483
|
-
x,
|
|
112484
|
-
y,
|
|
112485
|
-
width: Math.max(...xs) + margin - x,
|
|
112486
|
-
height: Math.max(...ys) + margin - y
|
|
112487
|
-
};
|
|
112488
|
-
}
|
|
112489
|
-
function overlaps$2(a, b) {
|
|
112490
|
-
return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
|
|
112491
|
-
}
|
|
112492
|
-
//#endregion
|
|
112493
|
-
//#region src/components/diagram/DiagramMap.ts
|
|
112494
|
-
var OWN$11 = ["diagram", "label"];
|
|
112495
|
-
/** How far a press moves before it drags the view and is not a click, in pixels. */
|
|
112496
|
-
var DRAG_FROM$1 = 3;
|
|
112497
|
-
/** How far an arrow key pans the diagram's view, in pixels; with Shift four times as far. */
|
|
112498
|
-
var KEY_STEP$1 = 40;
|
|
112499
|
-
/** The room the map keeps around the nodes and the view, as a share of its larger side. */
|
|
112500
|
-
var ROOM = .05;
|
|
112501
|
-
/** The pixels of a wheel's line, and how strongly a pixel of the wheel zooms, as the diagram's own wheel does. */
|
|
112502
|
-
var WHEEL_LINE$1 = 16;
|
|
112503
|
-
var WHEEL_ZOOM$1 = .002;
|
|
112504
|
-
/**
|
|
112505
|
-
* The whole of a diagram at a glance: its nodes, the part in view outlined and the rest dimmed. A click takes the view
|
|
112506
|
-
* there, a drag moves it, the wheel zooms; with the keys, the arrows pan and plus and minus zoom. The map has no
|
|
112507
|
-
* buttons: the diagram's commands zoom and fit. A diagram shows one in a corner of its own with `miniMap`; this
|
|
112508
|
-
* component puts it anywhere else, such as a side panel.
|
|
112509
|
-
*
|
|
112510
|
-
* @example
|
|
112511
|
-
* <Diagram ref={(d) => (diagram = d)} nodes={nodes} />
|
|
112512
|
-
* <DiagramMap ref={(m) => (m.diagram = diagram)} />
|
|
112513
|
-
*/
|
|
112514
|
-
var DiagramMap = class extends Control {
|
|
112515
|
-
constructor(props) {
|
|
112516
|
-
super("div", props);
|
|
112517
|
-
_defineProperty(this, "surface", void 0);
|
|
112518
|
-
_defineProperty(
|
|
112519
|
-
this,
|
|
112520
|
-
/** The nodes, each kind of them one path: the groups under the others, the selected over them; thousands cost three elements. */
|
|
112521
|
-
"groups",
|
|
112522
|
-
void 0
|
|
112523
|
-
);
|
|
112524
|
-
_defineProperty(this, "nodes", void 0);
|
|
112525
|
-
_defineProperty(this, "chosen", void 0);
|
|
112526
|
-
_defineProperty(this, "shade", void 0);
|
|
112527
|
-
_defineProperty(this, "frame", void 0);
|
|
112528
|
-
_defineProperty(this, "room", {
|
|
112529
|
-
width: 0,
|
|
112530
|
-
height: 0
|
|
112531
|
-
});
|
|
112532
|
-
_defineProperty(
|
|
112533
|
-
this,
|
|
112534
|
-
/** Around the nodes, in the diagram's units; `null` without nodes. */
|
|
112535
|
-
"nodeBounds",
|
|
112536
|
-
null
|
|
112537
|
-
);
|
|
112538
|
-
_defineProperty(
|
|
112539
|
-
this,
|
|
112540
|
-
/** The part of the diagram the map shows; kept while the view is dragged, so the map does not move under the pointer. */
|
|
112541
|
-
"box",
|
|
112542
|
-
{
|
|
112543
|
-
x: 0,
|
|
112544
|
-
y: 0,
|
|
112545
|
-
width: 1,
|
|
112546
|
-
height: 1
|
|
112547
|
-
}
|
|
112548
|
-
);
|
|
112549
|
-
_defineProperty(this, "held", false);
|
|
112550
|
-
_defineProperty(this, "watched", null);
|
|
112551
|
-
_defineProperty(this, "watches", []);
|
|
112552
|
-
_defineProperty(
|
|
112553
|
-
this,
|
|
112554
|
-
/** The press under way: the pointer, where it went down, how far from the middle of the view it took it, and whether it dragged. */
|
|
112555
|
-
"session",
|
|
112556
|
-
null
|
|
112557
|
-
);
|
|
112558
|
-
_defineProperty(this, "stops", []);
|
|
112559
|
-
const own = this.props ?? {};
|
|
112560
|
-
this.class.add("mx-diagram-map");
|
|
112561
|
-
this.attr.add({ role: "group" });
|
|
112562
|
-
put(this, "tabindex", "0");
|
|
112563
|
-
this.surface = svgComponent(this, "svg", "mx-diagram-map__surface");
|
|
112564
|
-
this.surface.attr.add({
|
|
112565
|
-
"aria-hidden": "true",
|
|
112566
|
-
focusable: "false",
|
|
112567
|
-
preserveAspectRatio: "none"
|
|
112568
|
-
});
|
|
112569
|
-
this.groups = svgComponent(this.surface, "path", "mx-diagram-map__node");
|
|
112570
|
-
this.groups.attr.add({ "data-group": "" });
|
|
112571
|
-
this.nodes = svgComponent(this.surface, "path", "mx-diagram-map__node");
|
|
112572
|
-
this.chosen = svgComponent(this.surface, "path", "mx-diagram-map__node");
|
|
112573
|
-
this.chosen.attr.add({ "data-selected": "" });
|
|
112574
|
-
this.shade = svgComponent(this.surface, "path", "mx-diagram-map__mask");
|
|
112575
|
-
this.frame = svgComponent(this.surface, "rect", "mx-diagram-map__view");
|
|
112576
|
-
for (const name of OWN$11) if (own[name] !== void 0) this.bindProperty(name, own[name]);
|
|
112577
|
-
this.observeProperty("diagram", () => this.watch());
|
|
112578
|
-
this.observeProperty("label", () => this.writeLabel());
|
|
112579
|
-
onLanguage(this, () => this.writeLabel());
|
|
112580
|
-
onLayout(this, "size", (size) => {
|
|
112581
|
-
this.room = size;
|
|
112582
|
-
this.drawView();
|
|
112583
|
-
});
|
|
112584
|
-
this.motif.on("pointerdown", (_, e) => this.pressed(e));
|
|
112585
|
-
this.motif.on("wheel", (_, e) => this.wheel(e));
|
|
112586
|
-
this.motif.on("keydown", (_, e) => this.keyDown(e));
|
|
112587
|
-
this.motif.setDisposable(() => {
|
|
112588
|
-
this.end();
|
|
112589
|
-
this.unwatch();
|
|
112590
|
-
});
|
|
112591
|
-
this.writeLabel();
|
|
112592
|
-
this.watch();
|
|
112593
|
-
}
|
|
112594
|
-
get diagram() {
|
|
112595
|
-
return this.getProperty("diagram") ?? null;
|
|
112596
|
-
}
|
|
112597
|
-
set diagram(value) {
|
|
112598
|
-
this.assignProperty("diagram", value);
|
|
112599
|
-
}
|
|
112600
|
-
get label() {
|
|
112601
|
-
return this.getProperty("label") ?? "";
|
|
112602
|
-
}
|
|
112603
|
-
set label(value) {
|
|
112604
|
-
this.assignProperty("label", value);
|
|
112605
|
-
}
|
|
112606
|
-
/** The diagram, while it is there. */
|
|
112607
|
-
get target() {
|
|
112608
|
-
const diagram = this.watched;
|
|
112609
|
-
return diagram && !diagram.isDisposed ? diagram : null;
|
|
112610
|
-
}
|
|
112611
|
-
/** Follows the diagram given: its nodes, its view and its selection. */
|
|
112612
|
-
watch() {
|
|
112613
|
-
const diagram = this.diagram;
|
|
112614
|
-
if (diagram === this.watched) return;
|
|
112615
|
-
this.unwatch();
|
|
112616
|
-
this.watched = diagram;
|
|
112617
|
-
if (diagram) this.watches.push(diagram.onContentChanged(() => this.draw()), diagram.onViewportChanged(() => this.drawView()), diagram.onSelectionChanged(() => this.drawNodes()));
|
|
112618
|
-
this.draw();
|
|
112619
|
-
}
|
|
112620
|
-
unwatch() {
|
|
112621
|
-
for (const watch of this.watches.splice(0)) watch.dispose();
|
|
112622
|
-
this.watched = null;
|
|
112623
|
-
}
|
|
112624
|
-
writeLabel() {
|
|
112625
|
-
put(this, "aria-label", this.label || uiLocale.strings.diagramMapName);
|
|
112626
|
-
put(this, "aria-roledescription", uiLocale.strings.diagramMapRole);
|
|
112627
|
-
put(this, "aria-description", uiLocale.strings.diagramMapHelp);
|
|
112628
|
-
}
|
|
112629
|
-
draw() {
|
|
112630
|
-
this.drawNodes();
|
|
112631
|
-
this.drawView();
|
|
112632
|
-
}
|
|
112633
|
-
/** A box for each node on the diagram's surface: a group outlined, a selected one marked. */
|
|
112634
|
-
drawNodes() {
|
|
112635
|
-
const drawn = this.target?.drawnNodes() ?? [];
|
|
112636
|
-
const selected = new Set(this.target?.selectedNodes.map((n) => n.id));
|
|
112637
|
-
let groups = "";
|
|
112638
|
-
let plain = "";
|
|
112639
|
-
let chosen = "";
|
|
112640
|
-
let bounds = null;
|
|
112641
|
-
for (const { node, rect, group } of drawn) {
|
|
112642
|
-
const box = `M${num$1(rect.x)} ${num$1(rect.y)}h${num$1(rect.width)}v${num$1(rect.height)}h${num$1(-rect.width)}Z`;
|
|
112643
|
-
if (group) groups += box;
|
|
112644
|
-
else if (selected.has(node.id)) chosen += box;
|
|
112645
|
-
else plain += box;
|
|
112646
|
-
bounds = bounds ? {
|
|
112647
|
-
left: Math.min(bounds.left, rect.x),
|
|
112648
|
-
top: Math.min(bounds.top, rect.y),
|
|
112649
|
-
right: Math.max(bounds.right, rect.x + rect.width),
|
|
112650
|
-
bottom: Math.max(bounds.bottom, rect.y + rect.height)
|
|
112651
|
-
} : {
|
|
112652
|
-
left: rect.x,
|
|
112653
|
-
top: rect.y,
|
|
112654
|
-
right: rect.x + rect.width,
|
|
112655
|
-
bottom: rect.y + rect.height
|
|
112656
|
-
};
|
|
112657
|
-
}
|
|
112658
|
-
put(this.groups, "d", groups || null);
|
|
112659
|
-
put(this.nodes, "d", plain || null);
|
|
112660
|
-
put(this.chosen, "d", chosen || null);
|
|
112661
|
-
this.nodeBounds = bounds ? {
|
|
112662
|
-
x: bounds.left,
|
|
112663
|
-
y: bounds.top,
|
|
112664
|
-
width: bounds.right - bounds.left,
|
|
112665
|
-
height: bounds.bottom - bounds.top
|
|
112666
|
-
} : null;
|
|
112667
|
-
}
|
|
112668
|
-
/** The part of the diagram the map shows, the view outlined in it and the rest of it dimmed. */
|
|
112669
|
-
drawView() {
|
|
112670
|
-
const diagram = this.target;
|
|
112671
|
-
const { width, height } = this.room;
|
|
112672
|
-
const on = !!diagram && width > 0 && height > 0;
|
|
112673
|
-
kept$2(this.frame, on);
|
|
112674
|
-
kept$2(this.shade, on);
|
|
112675
|
-
if (!diagram || !on) return;
|
|
112676
|
-
const view = diagram.visibleArea;
|
|
112677
|
-
if (!this.held) this.box = this.boxOf(view);
|
|
112678
|
-
const b = this.box;
|
|
112679
|
-
put(this.surface, "viewBox", `${num$1(b.x)} ${num$1(b.y)} ${num$1(b.width)} ${num$1(b.height)}`);
|
|
112680
|
-
put(this.frame, "x", num$1(view.x));
|
|
112681
|
-
put(this.frame, "y", num$1(view.y));
|
|
112682
|
-
put(this.frame, "width", num$1(view.width));
|
|
112683
|
-
put(this.frame, "height", num$1(view.height));
|
|
112684
|
-
put(this.shade, "d", `M${num$1(b.x)} ${num$1(b.y)}h${num$1(b.width)}v${num$1(b.height)}h${num$1(-b.width)}ZM${num$1(view.x)} ${num$1(view.y)}h${num$1(view.width)}v${num$1(view.height)}h${num$1(-view.width)}Z`);
|
|
112685
|
-
}
|
|
112686
|
-
/** What the map shows: the nodes and the view, with room around them, as wide for its height as the map is. */
|
|
112687
|
-
boxOf(view) {
|
|
112688
|
-
const n = this.nodeBounds;
|
|
112689
|
-
const left = Math.min(view.x, n?.x ?? view.x);
|
|
112690
|
-
const top = Math.min(view.y, n?.y ?? view.y);
|
|
112691
|
-
let width = Math.max(view.x + view.width, n ? n.x + n.width : -Infinity) - left;
|
|
112692
|
-
let height = Math.max(view.y + view.height, n ? n.y + n.height : -Infinity) - top;
|
|
112693
|
-
const room = Math.max(width, height) * ROOM;
|
|
112694
|
-
width = Math.max(1, width + room * 2);
|
|
112695
|
-
height = Math.max(1, height + room * 2);
|
|
112696
|
-
let x = left - room;
|
|
112697
|
-
let y = top - room;
|
|
112698
|
-
const ratio = this.room.width / this.room.height;
|
|
112699
|
-
if (width / height < ratio) {
|
|
112700
|
-
const wider = height * ratio;
|
|
112701
|
-
x -= (wider - width) / 2;
|
|
112702
|
-
width = wider;
|
|
112703
|
-
} else {
|
|
112704
|
-
const higher = width / ratio;
|
|
112705
|
-
y -= (higher - height) / 2;
|
|
112706
|
-
height = higher;
|
|
112707
|
-
}
|
|
112708
|
-
return {
|
|
112709
|
-
x,
|
|
112710
|
-
y,
|
|
112711
|
-
width,
|
|
112712
|
-
height
|
|
112713
|
-
};
|
|
112714
|
-
}
|
|
112715
|
-
/** The point of the diagram under a point of the page. */
|
|
112716
|
-
pointAt(clientX, clientY) {
|
|
112717
|
-
const r = rectOf(this.surface);
|
|
112718
|
-
const b = this.box;
|
|
112719
|
-
return {
|
|
112720
|
-
x: b.x + (clientX - r.left) / Math.max(1, r.width) * b.width,
|
|
112721
|
-
y: b.y + (clientY - r.top) / Math.max(1, r.height) * b.height
|
|
112722
|
-
};
|
|
112723
|
-
}
|
|
112724
|
-
pressed(e) {
|
|
112725
|
-
const diagram = this.target;
|
|
112726
|
-
if (!diagram || this.session || e.button !== 0 || !this.isEnabled || !diagram.pannable) return;
|
|
112727
|
-
e.preventDefault();
|
|
112728
|
-
this.focus();
|
|
112729
|
-
const at = this.pointAt(e.clientX, e.clientY);
|
|
112730
|
-
const view = diagram.visibleArea;
|
|
112731
|
-
const inside = at.x >= view.x && at.x <= view.x + view.width && at.y >= view.y && at.y <= view.y + view.height;
|
|
112732
|
-
this.held = true;
|
|
112733
|
-
this.session = {
|
|
112734
|
-
pointerId: e.pointerId,
|
|
112735
|
-
from: {
|
|
112736
|
-
x: e.clientX,
|
|
112737
|
-
y: e.clientY
|
|
112738
|
-
},
|
|
112739
|
-
at,
|
|
112740
|
-
grab: inside ? {
|
|
112741
|
-
x: at.x - (view.x + view.width / 2),
|
|
112742
|
-
y: at.y - (view.y + view.height / 2)
|
|
112743
|
-
} : {
|
|
112744
|
-
x: 0,
|
|
112745
|
-
y: 0
|
|
112746
|
-
},
|
|
112747
|
-
moved: false
|
|
112748
|
-
};
|
|
112749
|
-
this.stops.push(onWindow(this, "pointermove", (ev) => this.pointerMove(ev)), onWindow(this, "pointerup", (ev) => this.released(ev)), onWindow(this, "pointercancel", (ev) => this.released(ev)));
|
|
112750
|
-
}
|
|
112751
|
-
pointerMove(e) {
|
|
112752
|
-
const s = this.session;
|
|
112753
|
-
const diagram = this.target;
|
|
112754
|
-
if (!s || !diagram || e.pointerId !== s.pointerId) return;
|
|
112755
|
-
if (!s.moved) {
|
|
112756
|
-
if (Math.hypot(e.clientX - s.from.x, e.clientY - s.from.y) < DRAG_FROM$1) return;
|
|
112757
|
-
s.moved = true;
|
|
112758
|
-
this.attr.add({ setPointerCapture: s.pointerId });
|
|
112759
|
-
mark(this, "data-dragging", true);
|
|
112760
|
-
}
|
|
112761
|
-
const at = this.pointAt(e.clientX, e.clientY);
|
|
112762
|
-
diagram.centerOn({
|
|
112763
|
-
x: at.x - s.grab.x,
|
|
112764
|
-
y: at.y - s.grab.y
|
|
112765
|
-
});
|
|
112766
|
-
}
|
|
112767
|
-
released(e) {
|
|
112768
|
-
const s = this.session;
|
|
112769
|
-
if (!s || e.pointerId !== s.pointerId) return;
|
|
112770
|
-
this.end();
|
|
112771
|
-
if (!s.moved && e.type === "pointerup") this.target?.centerOn(s.at, { animate: true });
|
|
112772
|
-
this.drawView();
|
|
112773
|
-
}
|
|
112774
|
-
end() {
|
|
112775
|
-
for (const stop of this.stops.splice(0)) stop();
|
|
112776
|
-
this.session = null;
|
|
112777
|
-
this.held = false;
|
|
112778
|
-
mark(this, "data-dragging", false);
|
|
112779
|
-
}
|
|
112780
|
-
/** The wheel zooms the diagram around the point of it under the pointer. */
|
|
112781
|
-
wheel(e) {
|
|
112782
|
-
const diagram = this.target;
|
|
112783
|
-
if (!diagram || !this.isEnabled || !diagram.zoomable) return;
|
|
112784
|
-
e.preventDefault();
|
|
112785
|
-
const unit = e.deltaMode === 1 ? WHEEL_LINE$1 : e.deltaMode === 2 ? this.room.height : 1;
|
|
112786
|
-
const v = diagram.viewport;
|
|
112787
|
-
const zoom = Math.min(Math.max(v.zoom * Math.exp(-e.deltaY * unit * WHEEL_ZOOM$1), diagram.minZoom), diagram.maxZoom);
|
|
112788
|
-
const at = this.pointAt(e.clientX, e.clientY);
|
|
112789
|
-
diagram.setViewport({
|
|
112790
|
-
x: v.x + at.x * (v.zoom - zoom),
|
|
112791
|
-
y: v.y + at.y * (v.zoom - zoom),
|
|
112792
|
-
zoom
|
|
112793
|
-
});
|
|
112794
|
-
}
|
|
112795
|
-
/** The arrows show more of the diagram on their side; plus and minus zoom. */
|
|
112796
|
-
keyDown(e) {
|
|
112797
|
-
const diagram = this.target;
|
|
112798
|
-
if (!diagram || !this.isEnabled || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
112799
|
-
const v = diagram.viewport;
|
|
112800
|
-
const step = e.shiftKey ? 160 : KEY_STEP$1;
|
|
112801
|
-
const move = {
|
|
112802
|
-
ArrowLeft: [step, 0],
|
|
112803
|
-
ArrowRight: [-step, 0],
|
|
112804
|
-
ArrowUp: [0, step],
|
|
112805
|
-
ArrowDown: [0, -step]
|
|
112806
|
-
}[e.key];
|
|
112807
|
-
if (move) {
|
|
112808
|
-
if (!diagram.pannable) return;
|
|
112809
|
-
e.preventDefault();
|
|
112810
|
-
diagram.setViewport({
|
|
112811
|
-
x: v.x + move[0],
|
|
112812
|
-
y: v.y + move[1],
|
|
112813
|
-
zoom: v.zoom
|
|
112814
|
-
});
|
|
112815
|
-
return;
|
|
113121
|
+
connection,
|
|
113122
|
+
cancel: false
|
|
113123
|
+
};
|
|
113124
|
+
this.host.reconnecting(args);
|
|
113125
|
+
if (args.cancel) return;
|
|
113126
|
+
if (end === "source") {
|
|
113127
|
+
edge.source = connection.source;
|
|
113128
|
+
edge.sourcePort = connection.sourcePort;
|
|
113129
|
+
} else {
|
|
113130
|
+
edge.target = connection.target;
|
|
113131
|
+
edge.targetPort = connection.targetPort;
|
|
112816
113132
|
}
|
|
112817
|
-
|
|
112818
|
-
|
|
112819
|
-
|
|
112820
|
-
|
|
112821
|
-
|
|
112822
|
-
|
|
112823
|
-
|
|
113133
|
+
this.edgesChanged();
|
|
113134
|
+
this.host.reconnected({
|
|
113135
|
+
edge,
|
|
113136
|
+
end,
|
|
113137
|
+
previous
|
|
113138
|
+
});
|
|
113139
|
+
}
|
|
113140
|
+
/** Whether a port takes no more connections: `moving` does not count. */
|
|
113141
|
+
full(node, port, moving) {
|
|
113142
|
+
if (!port || port.maxConnections === void 0) return false;
|
|
113143
|
+
let count = 0;
|
|
113144
|
+
for (const edge of this.host.edges()) {
|
|
113145
|
+
if (edge === moving) continue;
|
|
113146
|
+
if (edge.source === node && edge.sourcePort === port.id || edge.target === node && edge.targetPort === port.id) count++;
|
|
112824
113147
|
}
|
|
113148
|
+
return count >= port.maxConnections;
|
|
112825
113149
|
}
|
|
112826
|
-
|
|
112827
|
-
|
|
112828
|
-
|
|
112829
|
-
}
|
|
112830
|
-
|
|
112831
|
-
|
|
112832
|
-
/** The
|
|
112833
|
-
|
|
112834
|
-
|
|
112835
|
-
|
|
112836
|
-
|
|
112837
|
-
|
|
112838
|
-
|
|
112839
|
-
{
|
|
112840
|
-
id: "right",
|
|
112841
|
-
side: "right",
|
|
112842
|
-
direction: "source"
|
|
112843
|
-
},
|
|
112844
|
-
{
|
|
112845
|
-
id: "bottom",
|
|
112846
|
-
side: "bottom",
|
|
112847
|
-
direction: "source"
|
|
112848
|
-
},
|
|
112849
|
-
{
|
|
112850
|
-
id: "left",
|
|
112851
|
-
side: "left",
|
|
112852
|
-
direction: "target"
|
|
113150
|
+
newId() {
|
|
113151
|
+
const ids = new Set(this.host.edges().map((e) => e.id));
|
|
113152
|
+
let n = ids.size + 1;
|
|
113153
|
+
while (ids.has(`edge-${n}`)) n++;
|
|
113154
|
+
return `edge-${n}`;
|
|
113155
|
+
}
|
|
113156
|
+
/** The point of the diagram under a point of the page, the view as it is now. */
|
|
113157
|
+
pointAt(origin, client) {
|
|
113158
|
+
const v = this.host.viewport();
|
|
113159
|
+
return {
|
|
113160
|
+
x: (client.x - origin.x - v.x) / v.zoom,
|
|
113161
|
+
y: (client.y - origin.y - v.y) / v.zoom
|
|
113162
|
+
};
|
|
112853
113163
|
}
|
|
112854
|
-
];
|
|
112855
|
-
var RESIZE_SIDES = [
|
|
112856
|
-
"n",
|
|
112857
|
-
"ne",
|
|
112858
|
-
"e",
|
|
112859
|
-
"se",
|
|
112860
|
-
"s",
|
|
112861
|
-
"sw",
|
|
112862
|
-
"w",
|
|
112863
|
-
"nw"
|
|
112864
|
-
];
|
|
112865
|
-
var STATUS_WORDS = {
|
|
112866
|
-
running: "diagramStatusRunning",
|
|
112867
|
-
done: "diagramStatusDone",
|
|
112868
|
-
error: "diagramStatusError",
|
|
112869
|
-
waiting: "diagramStatusWaiting",
|
|
112870
|
-
skipped: "diagramStatusSkipped"
|
|
112871
113164
|
};
|
|
112872
|
-
|
|
112873
|
-
|
|
112874
|
-
const word = uiLocale.strings[STATUS_WORDS[status]] ?? status;
|
|
112875
|
-
return detail ? `${word}: ${detail}` : word;
|
|
113165
|
+
function round(value) {
|
|
113166
|
+
return Math.round(value * 1e3) / 1e3;
|
|
112876
113167
|
}
|
|
113168
|
+
/** The rectangle around points, `margin` wider on every side. */
|
|
113169
|
+
function boundsOf(points, margin) {
|
|
113170
|
+
const xs = points.map((p) => p.x);
|
|
113171
|
+
const ys = points.map((p) => p.y);
|
|
113172
|
+
const x = Math.min(...xs) - margin;
|
|
113173
|
+
const y = Math.min(...ys) - margin;
|
|
113174
|
+
return {
|
|
113175
|
+
x,
|
|
113176
|
+
y,
|
|
113177
|
+
width: Math.max(...xs) + margin - x,
|
|
113178
|
+
height: Math.max(...ys) + margin - y
|
|
113179
|
+
};
|
|
113180
|
+
}
|
|
113181
|
+
function overlaps$2(a, b) {
|
|
113182
|
+
return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
|
|
113183
|
+
}
|
|
113184
|
+
//#endregion
|
|
113185
|
+
//#region src/components/diagram/DiagramMap.ts
|
|
113186
|
+
var OWN$11 = ["diagram", "label"];
|
|
113187
|
+
/** How far a press moves before it drags the view and is not a click, in pixels. */
|
|
113188
|
+
var DRAG_FROM$1 = 3;
|
|
113189
|
+
/** How far an arrow key pans the diagram's view, in pixels; with Shift four times as far. */
|
|
113190
|
+
var KEY_STEP$1 = 40;
|
|
113191
|
+
/** The room the map keeps around the nodes and the view, as a share of its larger side. */
|
|
113192
|
+
var ROOM = .05;
|
|
113193
|
+
/** The pixels of a wheel's line, and how strongly a pixel of the wheel zooms, as the diagram's own wheel does. */
|
|
113194
|
+
var WHEEL_LINE$1 = 16;
|
|
113195
|
+
var WHEEL_ZOOM$1 = .002;
|
|
112877
113196
|
/**
|
|
112878
|
-
*
|
|
112879
|
-
*
|
|
113197
|
+
* The whole of a diagram at a glance: its nodes, the part in view outlined and the rest dimmed. A click takes the view
|
|
113198
|
+
* there, a drag moves it, the wheel zooms; with the keys, the arrows pan and plus and minus zoom. The map has no
|
|
113199
|
+
* buttons: the diagram's commands zoom and fit. A diagram shows one in a corner of its own with `miniMap`; this
|
|
113200
|
+
* component puts it anywhere else, such as a side panel.
|
|
113201
|
+
*
|
|
113202
|
+
* @example
|
|
113203
|
+
* <Diagram ref={(d) => (diagram = d)} nodes={nodes} />
|
|
113204
|
+
* <DiagramMap ref={(m) => (m.diagram = diagram)} />
|
|
112880
113205
|
*/
|
|
112881
|
-
var
|
|
112882
|
-
constructor(
|
|
112883
|
-
|
|
113206
|
+
var DiagramMap = class extends Control {
|
|
113207
|
+
constructor(props) {
|
|
113208
|
+
super("div", props);
|
|
113209
|
+
_defineProperty(this, "surface", void 0);
|
|
112884
113210
|
_defineProperty(
|
|
112885
113211
|
this,
|
|
112886
|
-
/**
|
|
112887
|
-
"
|
|
113212
|
+
/** The nodes, each kind of them one path: the groups under the others, the selected over them; thousands cost three elements. */
|
|
113213
|
+
"groups",
|
|
112888
113214
|
void 0
|
|
112889
113215
|
);
|
|
113216
|
+
_defineProperty(this, "nodes", void 0);
|
|
113217
|
+
_defineProperty(this, "chosen", void 0);
|
|
113218
|
+
_defineProperty(this, "shade", void 0);
|
|
113219
|
+
_defineProperty(this, "frame", void 0);
|
|
113220
|
+
_defineProperty(this, "room", {
|
|
113221
|
+
width: 0,
|
|
113222
|
+
height: 0
|
|
113223
|
+
});
|
|
112890
113224
|
_defineProperty(
|
|
112891
113225
|
this,
|
|
112892
|
-
/**
|
|
112893
|
-
"
|
|
112894
|
-
nextId("diagram-node")
|
|
112895
|
-
);
|
|
112896
|
-
_defineProperty(this, "host", void 0);
|
|
112897
|
-
_defineProperty(
|
|
112898
|
-
this,
|
|
112899
|
-
/** A part for each port on each of its sides, by port and side. */
|
|
112900
|
-
"portParts",
|
|
112901
|
-
/* @__PURE__ */ new Map()
|
|
112902
|
-
);
|
|
112903
|
-
_defineProperty(this, "resizers", /* @__PURE__ */ new Map());
|
|
112904
|
-
_defineProperty(this, "context", void 0);
|
|
112905
|
-
_defineProperty(
|
|
112906
|
-
this,
|
|
112907
|
-
/** The parts of the content ports stand beside, by port, and where those parts are: the share of the way across and down the node to their middles. */
|
|
112908
|
-
"anchors",
|
|
112909
|
-
/* @__PURE__ */ new Map()
|
|
112910
|
-
);
|
|
112911
|
-
_defineProperty(this, "offsets", /* @__PURE__ */ new Map());
|
|
112912
|
-
_defineProperty(
|
|
112913
|
-
this,
|
|
112914
|
-
/** The ports, as read when it was drawn. */
|
|
112915
|
-
"portList",
|
|
112916
|
-
SIDE_PORTS
|
|
112917
|
-
);
|
|
112918
|
-
_defineProperty(this, "label", null);
|
|
112919
|
-
_defineProperty(
|
|
112920
|
-
this,
|
|
112921
|
-
/** The mark of its status in its corner, while it has one. */
|
|
112922
|
-
"statusMark",
|
|
112923
|
-
null
|
|
112924
|
-
);
|
|
112925
|
-
_defineProperty(this, "kind", null);
|
|
112926
|
-
_defineProperty(
|
|
112927
|
-
this,
|
|
112928
|
-
/** The kind whose content it holds now. */
|
|
112929
|
-
"made",
|
|
112930
|
-
null
|
|
112931
|
-
);
|
|
112932
|
-
_defineProperty(
|
|
112933
|
-
this,
|
|
112934
|
-
/** Whether its content is made and laid out: it came into view once, or the diagram shows every node. */
|
|
112935
|
-
"entered",
|
|
112936
|
-
false
|
|
112937
|
-
);
|
|
112938
|
-
_defineProperty(
|
|
112939
|
-
this,
|
|
112940
|
-
/** Whether it is on the page: it lies in view, or the diagram shows every node. */
|
|
112941
|
-
"live",
|
|
112942
|
-
true
|
|
112943
|
-
);
|
|
112944
|
-
_defineProperty(
|
|
112945
|
-
this,
|
|
112946
|
-
/** The part a press drags the node from, when the kind's content named one. */
|
|
112947
|
-
"handle",
|
|
112948
|
-
null
|
|
112949
|
-
);
|
|
112950
|
-
_defineProperty(
|
|
112951
|
-
this,
|
|
112952
|
-
/** What names it, when the kind's content gave it (`context.label`), and what stops the name following its data. */
|
|
112953
|
-
"naming",
|
|
113226
|
+
/** Around the nodes, in the diagram's units; `null` without nodes. */
|
|
113227
|
+
"nodeBounds",
|
|
112954
113228
|
null
|
|
112955
113229
|
);
|
|
112956
|
-
_defineProperty(this, "stopNaming", null);
|
|
112957
|
-
_defineProperty(
|
|
112958
|
-
this,
|
|
112959
|
-
/** The app's and the kind's classes and the app's style properties written last, so those taken away come off. */
|
|
112960
|
-
"drawnClasses",
|
|
112961
|
-
[]
|
|
112962
|
-
);
|
|
112963
|
-
_defineProperty(this, "drawnStyle", []);
|
|
112964
|
-
_defineProperty(this, "node", void 0);
|
|
112965
113230
|
_defineProperty(
|
|
112966
113231
|
this,
|
|
112967
|
-
/**
|
|
112968
|
-
"
|
|
113232
|
+
/** The part of the diagram the map shows; kept while the view is dragged, so the map does not move under the pointer. */
|
|
113233
|
+
"box",
|
|
112969
113234
|
{
|
|
112970
|
-
|
|
112971
|
-
|
|
112972
|
-
|
|
112973
|
-
|
|
112974
|
-
_defineProperty(
|
|
112975
|
-
this,
|
|
112976
|
-
/** Hidden in a collapsed group. */
|
|
112977
|
-
"hidden",
|
|
112978
|
-
false
|
|
112979
|
-
);
|
|
112980
|
-
_defineProperty(
|
|
112981
|
-
this,
|
|
112982
|
-
/** The share of the way across and down the node to the middle of each part a port stands beside; a part not laid out is left out. */
|
|
112983
|
-
"anchorsRead",
|
|
112984
|
-
() => {
|
|
112985
|
-
const offsets = /* @__PURE__ */ new Map();
|
|
112986
|
-
const box = rectOf(this.part);
|
|
112987
|
-
if (box.width <= 0 || box.height <= 0) return offsets;
|
|
112988
|
-
for (const [id, at] of this.anchors) {
|
|
112989
|
-
const r = rectOf(at);
|
|
112990
|
-
if (r.width <= 0 && r.height <= 0) continue;
|
|
112991
|
-
offsets.set(id, {
|
|
112992
|
-
across: (r.left + r.width / 2 - box.left) / box.width,
|
|
112993
|
-
down: (r.top + r.height / 2 - box.top) / box.height
|
|
112994
|
-
});
|
|
112995
|
-
}
|
|
112996
|
-
return offsets;
|
|
113235
|
+
x: 0,
|
|
113236
|
+
y: 0,
|
|
113237
|
+
width: 1,
|
|
113238
|
+
height: 1
|
|
112997
113239
|
}
|
|
112998
113240
|
);
|
|
113241
|
+
_defineProperty(this, "held", false);
|
|
113242
|
+
_defineProperty(this, "watched", null);
|
|
113243
|
+
_defineProperty(this, "watches", []);
|
|
112999
113244
|
_defineProperty(
|
|
113000
113245
|
this,
|
|
113001
|
-
/** The
|
|
113002
|
-
"
|
|
113003
|
-
|
|
113004
|
-
if (offsets.size === this.offsets.size && [...offsets].every(([id, at]) => {
|
|
113005
|
-
const was = this.offsets.get(id);
|
|
113006
|
-
return !!was && Math.abs(was.across - at.across) < 1e-4 && Math.abs(was.down - at.down) < 1e-4;
|
|
113007
|
-
})) return;
|
|
113008
|
-
this.offsets = offsets;
|
|
113009
|
-
this.drawPorts();
|
|
113010
|
-
this.host.sized(this);
|
|
113011
|
-
}
|
|
113246
|
+
/** The press under way: the pointer, where it went down, how far from the middle of the view it took it, and whether it dragged. */
|
|
113247
|
+
"session",
|
|
113248
|
+
null
|
|
113012
113249
|
);
|
|
113013
|
-
this
|
|
113014
|
-
this.
|
|
113015
|
-
this.
|
|
113016
|
-
this.
|
|
113017
|
-
|
|
113018
|
-
|
|
113250
|
+
_defineProperty(this, "stops", []);
|
|
113251
|
+
const own = this.props ?? {};
|
|
113252
|
+
this.class.add("mx-diagram-map");
|
|
113253
|
+
this.attr.add({ role: "group" });
|
|
113254
|
+
put(this, "tabindex", "0");
|
|
113255
|
+
this.surface = svgComponent(this, "svg", "mx-diagram-map__surface");
|
|
113256
|
+
this.surface.attr.add({
|
|
113257
|
+
"aria-hidden": "true",
|
|
113258
|
+
focusable: "false",
|
|
113259
|
+
preserveAspectRatio: "none"
|
|
113019
113260
|
});
|
|
113020
|
-
this.
|
|
113021
|
-
|
|
113022
|
-
this.
|
|
113023
|
-
|
|
113024
|
-
|
|
113025
|
-
|
|
113026
|
-
|
|
113027
|
-
|
|
113028
|
-
|
|
113029
|
-
|
|
113030
|
-
|
|
113031
|
-
|
|
113032
|
-
|
|
113033
|
-
|
|
113034
|
-
anchor(id, at) {
|
|
113035
|
-
if (at) view.anchors.set(id, at);
|
|
113036
|
-
else view.anchors.delete(id);
|
|
113037
|
-
view.readAnchors();
|
|
113038
|
-
},
|
|
113039
|
-
label(read) {
|
|
113040
|
-
view.stopNaming?.();
|
|
113041
|
-
view.naming = read;
|
|
113042
|
-
view.stopNaming = effect(() => {
|
|
113043
|
-
const name = read();
|
|
113044
|
-
untracked(() => put(view.part, "aria-label", name || view.node.id));
|
|
113045
|
-
});
|
|
113046
|
-
}
|
|
113047
|
-
};
|
|
113048
|
-
this.part.motif.setDisposable(() => this.stopNaming?.());
|
|
113049
|
-
this.part.motif.on("pointerdown", (_, e) => this.pressed(e));
|
|
113050
|
-
this.draw();
|
|
113051
|
-
}
|
|
113052
|
-
/** Makes its content and lays it out: the first time it comes into view, or at once in a diagram that shows every node. */
|
|
113053
|
-
enter() {
|
|
113054
|
-
if (this.entered) return;
|
|
113055
|
-
this.entered = true;
|
|
113056
|
-
onLayout(this.part, "size", (size) => {
|
|
113057
|
-
if (!size.width && !size.height) return;
|
|
113058
|
-
this.size = size;
|
|
113059
|
-
this.host.sized(this);
|
|
113060
|
-
this.readAnchors();
|
|
113261
|
+
this.groups = svgComponent(this.surface, "path", "mx-diagram-map__node");
|
|
113262
|
+
this.groups.attr.add({ "data-group": "" });
|
|
113263
|
+
this.nodes = svgComponent(this.surface, "path", "mx-diagram-map__node");
|
|
113264
|
+
this.chosen = svgComponent(this.surface, "path", "mx-diagram-map__node");
|
|
113265
|
+
this.chosen.attr.add({ "data-selected": "" });
|
|
113266
|
+
this.shade = svgComponent(this.surface, "path", "mx-diagram-map__mask");
|
|
113267
|
+
this.frame = svgComponent(this.surface, "rect", "mx-diagram-map__view");
|
|
113268
|
+
for (const name of OWN$11) if (own[name] !== void 0) this.bindProperty(name, own[name]);
|
|
113269
|
+
this.observeProperty("diagram", () => this.watch());
|
|
113270
|
+
this.observeProperty("label", () => this.writeLabel());
|
|
113271
|
+
onLanguage(this, () => this.writeLabel());
|
|
113272
|
+
onLayout(this, "size", (size) => {
|
|
113273
|
+
this.room = size;
|
|
113274
|
+
this.drawView();
|
|
113061
113275
|
});
|
|
113062
|
-
this.
|
|
113063
|
-
|
|
113064
|
-
|
|
113065
|
-
|
|
113066
|
-
|
|
113067
|
-
|
|
113068
|
-
}
|
|
113069
|
-
/** Its ports: the node's own, its kind's, or one in the middle of each side. */
|
|
113070
|
-
get ports() {
|
|
113071
|
-
return this.portList;
|
|
113072
|
-
}
|
|
113073
|
-
/** Whether the node or its kind names ports of its own. */
|
|
113074
|
-
get hasOwnPorts() {
|
|
113075
|
-
return !!(this.node.ports ?? this.kind?.ports);
|
|
113076
|
-
}
|
|
113077
|
-
/** Every port on each of its sides, where it stands now. */
|
|
113078
|
-
get places() {
|
|
113079
|
-
const rect = this.rect;
|
|
113080
|
-
const places = [];
|
|
113081
|
-
for (const port of this.portList) for (const side of sidesOf(port)) places.push({
|
|
113082
|
-
port,
|
|
113083
|
-
side,
|
|
113084
|
-
point: portPoint(rect, side, this.offsetOf(port, side))
|
|
113276
|
+
this.motif.on("pointerdown", (_, e) => this.pressed(e));
|
|
113277
|
+
this.motif.on("wheel", (_, e) => this.wheel(e));
|
|
113278
|
+
this.motif.on("keydown", (_, e) => this.keyDown(e));
|
|
113279
|
+
this.motif.setDisposable(() => {
|
|
113280
|
+
this.end();
|
|
113281
|
+
this.unwatch();
|
|
113085
113282
|
});
|
|
113086
|
-
|
|
113087
|
-
|
|
113088
|
-
/** Where a port stands: on the one of its sides nearest `toward`; `null` for a port it does not have. */
|
|
113089
|
-
placeOf(id, toward) {
|
|
113090
|
-
const port = this.port(id);
|
|
113091
|
-
if (!port) return null;
|
|
113092
|
-
const rect = this.rect;
|
|
113093
|
-
let best = null;
|
|
113094
|
-
let nearest = Infinity;
|
|
113095
|
-
for (const side of sidesOf(port)) {
|
|
113096
|
-
const point = portPoint(rect, side, this.offsetOf(port, side));
|
|
113097
|
-
const d = Math.hypot(point.x - toward.x, point.y - toward.y);
|
|
113098
|
-
if (d < nearest) {
|
|
113099
|
-
nearest = d;
|
|
113100
|
-
best = {
|
|
113101
|
-
port,
|
|
113102
|
-
side,
|
|
113103
|
-
point
|
|
113104
|
-
};
|
|
113105
|
-
}
|
|
113106
|
-
}
|
|
113107
|
-
return best;
|
|
113108
|
-
}
|
|
113109
|
-
/** How far along a side a port stands: beside the part its content anchors it to, else at its own offset. */
|
|
113110
|
-
offsetOf(port, side) {
|
|
113111
|
-
const at = this.offsets.get(port.id);
|
|
113112
|
-
if (at) return side === "left" || side === "right" ? at.down : at.across;
|
|
113113
|
-
return port.offset ?? .5;
|
|
113114
|
-
}
|
|
113115
|
-
/** Whether it holds other nodes. */
|
|
113116
|
-
get isGroup() {
|
|
113117
|
-
return !!this.kind?.group;
|
|
113118
|
-
}
|
|
113119
|
-
/** Whether it collapses to its header: a group, or a node of a kind that says so. */
|
|
113120
|
-
get isCollapsible() {
|
|
113121
|
-
return !!(this.kind?.group || this.kind?.collapsible);
|
|
113122
|
-
}
|
|
113123
|
-
/** Whether the user may resize it (a collapsed node not, until it opens), and the smallest size a resize leaves. */
|
|
113124
|
-
get isResizable() {
|
|
113125
|
-
if (this.isCollapsible && this.node.collapsed) return false;
|
|
113126
|
-
return this.node.resizable ?? this.kind?.resizable ?? false;
|
|
113127
|
-
}
|
|
113128
|
-
get minSize() {
|
|
113129
|
-
return {
|
|
113130
|
-
width: this.kind?.minWidth ?? 40,
|
|
113131
|
-
height: this.kind?.minHeight ?? 24
|
|
113132
|
-
};
|
|
113133
|
-
}
|
|
113134
|
-
port(id) {
|
|
113135
|
-
return id === void 0 ? null : this.ports.find((p) => p.id === id) ?? null;
|
|
113136
|
-
}
|
|
113137
|
-
/** Marks a port as the end a connection being drawn would take, or would be refused at; none for `null`. */
|
|
113138
|
-
markPort(id, state) {
|
|
113139
|
-
for (const { port, part: p } of this.portParts.values()) {
|
|
113140
|
-
mark(p, "data-target", port === id && state === "target");
|
|
113141
|
-
mark(p, "data-refused", port === id && state === "refused");
|
|
113142
|
-
}
|
|
113143
|
-
}
|
|
113144
|
-
/** Marks the ports a connection being drawn may end at; none for `null`. */
|
|
113145
|
-
markAvailable(ids) {
|
|
113146
|
-
for (const { port, part: p } of this.portParts.values()) mark(p, "data-available", !!ids?.has(port));
|
|
113147
|
-
}
|
|
113148
|
-
markSelected(on) {
|
|
113149
|
-
mark(this.part, "data-selected", on);
|
|
113150
|
-
}
|
|
113151
|
-
markMovable(on) {
|
|
113152
|
-
mark(this.part, "data-movable", on);
|
|
113283
|
+
this.writeLabel();
|
|
113284
|
+
this.watch();
|
|
113153
113285
|
}
|
|
113154
|
-
|
|
113155
|
-
|
|
113286
|
+
get diagram() {
|
|
113287
|
+
return this.getProperty("diagram") ?? null;
|
|
113156
113288
|
}
|
|
113157
|
-
|
|
113158
|
-
|
|
113159
|
-
mark(this.part, "data-active", on);
|
|
113289
|
+
set diagram(value) {
|
|
113290
|
+
this.assignProperty("diagram", value);
|
|
113160
113291
|
}
|
|
113161
|
-
|
|
113162
|
-
|
|
113163
|
-
this.hidden = on;
|
|
113164
|
-
if (this.entered) kept$2(this.part, this.live && !on);
|
|
113292
|
+
get label() {
|
|
113293
|
+
return this.getProperty("label") ?? "";
|
|
113165
113294
|
}
|
|
113166
|
-
|
|
113167
|
-
|
|
113168
|
-
mark(this.part, "data-drop-target", on);
|
|
113295
|
+
set label(value) {
|
|
113296
|
+
this.assignProperty("label", value);
|
|
113169
113297
|
}
|
|
113170
|
-
/**
|
|
113171
|
-
get
|
|
113172
|
-
|
|
113298
|
+
/** The diagram, while it is there. */
|
|
113299
|
+
get target() {
|
|
113300
|
+
const diagram = this.watched;
|
|
113301
|
+
return diagram && !diagram.isDisposed ? diagram : null;
|
|
113173
113302
|
}
|
|
113174
|
-
/**
|
|
113175
|
-
|
|
113176
|
-
const
|
|
113177
|
-
|
|
113178
|
-
this.
|
|
113179
|
-
this.
|
|
113180
|
-
if (
|
|
113181
|
-
|
|
113182
|
-
put(this.part, "data-id", node.id);
|
|
113183
|
-
put(this.part, "data-kind", node.kind ?? null);
|
|
113184
|
-
this.drawPlace();
|
|
113185
|
-
this.drawSize();
|
|
113186
|
-
if (kind.content) kind.update?.(this.context);
|
|
113187
|
-
else if (this.label) text$1(this.label, node.text ?? "");
|
|
113188
|
-
if (!this.naming) put(this.part, "aria-label", this.name);
|
|
113189
|
-
put(this.part, "aria-roledescription", uiLocale.strings.diagramNode);
|
|
113190
|
-
mark(this.part, "data-no-connect", node.connectable === false);
|
|
113191
|
-
mark(this.part, "data-group", !!kind.group);
|
|
113192
|
-
mark(this.part, "data-collapsed", this.isCollapsible && !!node.collapsed);
|
|
113193
|
-
mark(this.part, "data-resizable", this.isResizable);
|
|
113194
|
-
this.drawLook(kind);
|
|
113195
|
-
this.drawStatus();
|
|
113196
|
-
this.drawPorts();
|
|
113197
|
-
this.drawResizers();
|
|
113198
|
-
this.readAnchors();
|
|
113303
|
+
/** Follows the diagram given: its nodes, its view and its selection. */
|
|
113304
|
+
watch() {
|
|
113305
|
+
const diagram = this.diagram;
|
|
113306
|
+
if (diagram === this.watched) return;
|
|
113307
|
+
this.unwatch();
|
|
113308
|
+
this.watched = diagram;
|
|
113309
|
+
if (diagram) this.watches.push(diagram.onContentChanged(() => this.draw()), diagram.onViewportChanged(() => this.drawView()), diagram.onSelectionChanged(() => this.drawNodes()));
|
|
113310
|
+
this.draw();
|
|
113199
113311
|
}
|
|
113200
|
-
|
|
113201
|
-
|
|
113202
|
-
|
|
113312
|
+
unwatch() {
|
|
113313
|
+
for (const watch of this.watches.splice(0)) watch.dispose();
|
|
113314
|
+
this.watched = null;
|
|
113203
113315
|
}
|
|
113204
|
-
|
|
113205
|
-
|
|
113206
|
-
|
|
113207
|
-
|
|
113208
|
-
drawSize() {
|
|
113209
|
-
const given = this.given;
|
|
113210
|
-
const kind = this.kind;
|
|
113211
|
-
css(this.part, "width", given.width !== null ? `${given.width}px` : "");
|
|
113212
|
-
css(this.part, "max-width", given.width !== null ? "none" : "");
|
|
113213
|
-
css(this.part, "height", given.height !== null ? `${given.height}px` : "");
|
|
113214
|
-
const min = this.minSize;
|
|
113215
|
-
const minWidth = kind?.minWidth ?? (this.isResizable ? min.width : given.width !== null ? 0 : null);
|
|
113216
|
-
const minHeight = kind?.minHeight ?? (this.isResizable ? min.height : given.height !== null ? 0 : null);
|
|
113217
|
-
css(this.part, "min-width", this.folded("horizontal") ? "0" : minWidth !== null ? `${minWidth}px` : "");
|
|
113218
|
-
css(this.part, "min-height", this.folded("vertical") ? "0" : minHeight !== null ? `${minHeight}px` : "");
|
|
113316
|
+
writeLabel() {
|
|
113317
|
+
put(this, "aria-label", this.label || uiLocale.strings.diagramMapName);
|
|
113318
|
+
put(this, "aria-roledescription", uiLocale.strings.diagramMapRole);
|
|
113319
|
+
put(this, "aria-description", uiLocale.strings.diagramMapHelp);
|
|
113219
113320
|
}
|
|
113220
|
-
|
|
113221
|
-
|
|
113222
|
-
|
|
113321
|
+
draw() {
|
|
113322
|
+
this.drawNodes();
|
|
113323
|
+
this.drawView();
|
|
113223
113324
|
}
|
|
113224
|
-
/**
|
|
113225
|
-
|
|
113226
|
-
const
|
|
113227
|
-
|
|
113325
|
+
/** A box for each node on the diagram's surface: a group outlined, a selected one marked. */
|
|
113326
|
+
drawNodes() {
|
|
113327
|
+
const drawn = this.target?.drawnNodes() ?? [];
|
|
113328
|
+
const selected = new Set(this.target?.selectedNodes.map((n) => n.id));
|
|
113329
|
+
let groups = "";
|
|
113330
|
+
let plain = "";
|
|
113331
|
+
let chosen = "";
|
|
113332
|
+
let bounds = null;
|
|
113333
|
+
for (const { node, rect, group } of drawn) {
|
|
113334
|
+
const box = `M${num$1(rect.x)} ${num$1(rect.y)}h${num$1(rect.width)}v${num$1(rect.height)}h${num$1(-rect.width)}Z`;
|
|
113335
|
+
if (group) groups += box;
|
|
113336
|
+
else if (selected.has(node.id)) chosen += box;
|
|
113337
|
+
else plain += box;
|
|
113338
|
+
bounds = bounds ? {
|
|
113339
|
+
left: Math.min(bounds.left, rect.x),
|
|
113340
|
+
top: Math.min(bounds.top, rect.y),
|
|
113341
|
+
right: Math.max(bounds.right, rect.x + rect.width),
|
|
113342
|
+
bottom: Math.max(bounds.bottom, rect.y + rect.height)
|
|
113343
|
+
} : {
|
|
113344
|
+
left: rect.x,
|
|
113345
|
+
top: rect.y,
|
|
113346
|
+
right: rect.x + rect.width,
|
|
113347
|
+
bottom: rect.y + rect.height
|
|
113348
|
+
};
|
|
113349
|
+
}
|
|
113350
|
+
put(this.groups, "d", groups || null);
|
|
113351
|
+
put(this.nodes, "d", plain || null);
|
|
113352
|
+
put(this.chosen, "d", chosen || null);
|
|
113353
|
+
this.nodeBounds = bounds ? {
|
|
113354
|
+
x: bounds.left,
|
|
113355
|
+
y: bounds.top,
|
|
113356
|
+
width: bounds.right - bounds.left,
|
|
113357
|
+
height: bounds.bottom - bounds.top
|
|
113358
|
+
} : null;
|
|
113228
113359
|
}
|
|
113229
|
-
/**
|
|
113230
|
-
|
|
113231
|
-
|
|
113232
|
-
|
|
113233
|
-
|
|
113234
|
-
|
|
113235
|
-
|
|
113236
|
-
|
|
113237
|
-
const
|
|
113238
|
-
|
|
113360
|
+
/** The part of the diagram the map shows, the view outlined in it and the rest of it dimmed. */
|
|
113361
|
+
drawView() {
|
|
113362
|
+
const diagram = this.target;
|
|
113363
|
+
const { width, height } = this.room;
|
|
113364
|
+
const on = !!diagram && width > 0 && height > 0;
|
|
113365
|
+
kept$2(this.frame, on);
|
|
113366
|
+
kept$2(this.shade, on);
|
|
113367
|
+
if (!diagram || !on) return;
|
|
113368
|
+
const view = diagram.visibleArea;
|
|
113369
|
+
if (!this.held) this.box = this.boxOf(view);
|
|
113370
|
+
const b = this.box;
|
|
113371
|
+
put(this.surface, "viewBox", `${num$1(b.x)} ${num$1(b.y)} ${num$1(b.width)} ${num$1(b.height)}`);
|
|
113372
|
+
put(this.frame, "x", num$1(view.x));
|
|
113373
|
+
put(this.frame, "y", num$1(view.y));
|
|
113374
|
+
put(this.frame, "width", num$1(view.width));
|
|
113375
|
+
put(this.frame, "height", num$1(view.height));
|
|
113376
|
+
put(this.shade, "d", `M${num$1(b.x)} ${num$1(b.y)}h${num$1(b.width)}v${num$1(b.height)}h${num$1(-b.width)}ZM${num$1(view.x)} ${num$1(view.y)}h${num$1(view.width)}v${num$1(view.height)}h${num$1(-view.width)}Z`);
|
|
113377
|
+
}
|
|
113378
|
+
/** What the map shows: the nodes and the view, with room around them, as wide for its height as the map is. */
|
|
113379
|
+
boxOf(view) {
|
|
113380
|
+
const n = this.nodeBounds;
|
|
113381
|
+
const left = Math.min(view.x, n?.x ?? view.x);
|
|
113382
|
+
const top = Math.min(view.y, n?.y ?? view.y);
|
|
113383
|
+
let width = Math.max(view.x + view.width, n ? n.x + n.width : -Infinity) - left;
|
|
113384
|
+
let height = Math.max(view.y + view.height, n ? n.y + n.height : -Infinity) - top;
|
|
113385
|
+
const room = Math.max(width, height) * ROOM;
|
|
113386
|
+
width = Math.max(1, width + room * 2);
|
|
113387
|
+
height = Math.max(1, height + room * 2);
|
|
113388
|
+
let x = left - room;
|
|
113389
|
+
let y = top - room;
|
|
113390
|
+
const ratio = this.room.width / this.room.height;
|
|
113391
|
+
if (width / height < ratio) {
|
|
113392
|
+
const wider = height * ratio;
|
|
113393
|
+
x -= (wider - width) / 2;
|
|
113394
|
+
width = wider;
|
|
113395
|
+
} else {
|
|
113396
|
+
const higher = width / ratio;
|
|
113397
|
+
y -= (higher - height) / 2;
|
|
113398
|
+
height = higher;
|
|
113399
|
+
}
|
|
113239
113400
|
return {
|
|
113240
|
-
x
|
|
113241
|
-
y
|
|
113401
|
+
x,
|
|
113402
|
+
y,
|
|
113242
113403
|
width,
|
|
113243
113404
|
height
|
|
113244
113405
|
};
|
|
113245
113406
|
}
|
|
113246
|
-
/** The
|
|
113247
|
-
|
|
113248
|
-
const
|
|
113407
|
+
/** The point of the diagram under a point of the page. */
|
|
113408
|
+
pointAt(clientX, clientY) {
|
|
113409
|
+
const r = rectOf(this.surface);
|
|
113410
|
+
const b = this.box;
|
|
113249
113411
|
return {
|
|
113250
|
-
|
|
113251
|
-
|
|
113412
|
+
x: b.x + (clientX - r.left) / Math.max(1, r.width) * b.width,
|
|
113413
|
+
y: b.y + (clientY - r.top) / Math.max(1, r.height) * b.height
|
|
113252
113414
|
};
|
|
113253
113415
|
}
|
|
113254
|
-
/** Whether it is collapsed the way given: `'vertical'` to the height of its header, `'horizontal'` to its width. */
|
|
113255
|
-
folded(way) {
|
|
113256
|
-
return this.isCollapsible && !!this.node.collapsed && (this.kind?.collapse ?? "vertical") === way;
|
|
113257
|
-
}
|
|
113258
|
-
/** Reads where the parts its ports stand beside are, with the window's next run. */
|
|
113259
|
-
readAnchors() {
|
|
113260
|
-
if (this.anchors.size || this.offsets.size) measure(this.part, this.anchorsRead, this.anchorsWritten);
|
|
113261
|
-
}
|
|
113262
|
-
/** Makes the content of a kind, in place of what the last one made. */
|
|
113263
|
-
build(kind) {
|
|
113264
|
-
clearParts(this.body);
|
|
113265
|
-
this.label = null;
|
|
113266
|
-
this.handle = null;
|
|
113267
|
-
this.anchors.clear();
|
|
113268
|
-
this.offsets = /* @__PURE__ */ new Map();
|
|
113269
|
-
this.stopNaming?.();
|
|
113270
|
-
this.stopNaming = null;
|
|
113271
|
-
this.naming = null;
|
|
113272
|
-
this.made = kind;
|
|
113273
|
-
if (!kind.content) {
|
|
113274
|
-
this.label = part(this.body, "div", "mx-diagram__node-text");
|
|
113275
|
-
return;
|
|
113276
|
-
}
|
|
113277
|
-
const made = kind.content(this.context);
|
|
113278
|
-
if (made instanceof ComponentBase) this.body.controls.add(made);
|
|
113279
|
-
else if (made !== void 0 && made !== null && made !== "") text$1(this.body, String(made));
|
|
113280
|
-
}
|
|
113281
|
-
/**
|
|
113282
|
-
* A press on the node: a resize handle resizes, a port draws a connection, a control of the content keeps it, and
|
|
113283
|
-
* the rest drags the node (off a drag handle, it only selects).
|
|
113284
|
-
*/
|
|
113285
113416
|
pressed(e) {
|
|
113286
|
-
|
|
113287
|
-
|
|
113288
|
-
|
|
113289
|
-
|
|
113290
|
-
|
|
113291
|
-
|
|
113292
|
-
|
|
113293
|
-
|
|
113294
|
-
|
|
113295
|
-
|
|
113296
|
-
|
|
113297
|
-
|
|
113417
|
+
const diagram = this.target;
|
|
113418
|
+
if (!diagram || this.session || e.button !== 0 || !this.isEnabled || !diagram.pannable) return;
|
|
113419
|
+
e.preventDefault();
|
|
113420
|
+
this.focus();
|
|
113421
|
+
const at = this.pointAt(e.clientX, e.clientY);
|
|
113422
|
+
const view = diagram.visibleArea;
|
|
113423
|
+
const inside = at.x >= view.x && at.x <= view.x + view.width && at.y >= view.y && at.y <= view.y + view.height;
|
|
113424
|
+
this.held = true;
|
|
113425
|
+
this.session = {
|
|
113426
|
+
pointerId: e.pointerId,
|
|
113427
|
+
from: {
|
|
113428
|
+
x: e.clientX,
|
|
113429
|
+
y: e.clientY
|
|
113430
|
+
},
|
|
113431
|
+
at,
|
|
113432
|
+
grab: inside ? {
|
|
113433
|
+
x: at.x - (view.x + view.width / 2),
|
|
113434
|
+
y: at.y - (view.y + view.height / 2)
|
|
113435
|
+
} : {
|
|
113436
|
+
x: 0,
|
|
113437
|
+
y: 0
|
|
113438
|
+
},
|
|
113439
|
+
moved: false
|
|
113440
|
+
};
|
|
113441
|
+
this.stops.push(onWindow(this, "pointermove", (ev) => this.pointerMove(ev)), onWindow(this, "pointerup", (ev) => this.released(ev)), onWindow(this, "pointercancel", (ev) => this.released(ev)));
|
|
113298
113442
|
}
|
|
113299
|
-
|
|
113300
|
-
|
|
113301
|
-
|
|
113302
|
-
|
|
113303
|
-
|
|
113304
|
-
|
|
113305
|
-
|
|
113306
|
-
|
|
113307
|
-
|
|
113308
|
-
if (child instanceof Control && (child.focusPart !== null && child.focusPart !== child || !child.isEnabled)) return true;
|
|
113309
|
-
return this.fromControl(child, e);
|
|
113443
|
+
pointerMove(e) {
|
|
113444
|
+
const s = this.session;
|
|
113445
|
+
const diagram = this.target;
|
|
113446
|
+
if (!s || !diagram || e.pointerId !== s.pointerId) return;
|
|
113447
|
+
if (!s.moved) {
|
|
113448
|
+
if (Math.hypot(e.clientX - s.from.x, e.clientY - s.from.y) < DRAG_FROM$1) return;
|
|
113449
|
+
s.moved = true;
|
|
113450
|
+
this.attr.add({ setPointerCapture: s.pointerId });
|
|
113451
|
+
mark(this, "data-dragging", true);
|
|
113310
113452
|
}
|
|
113311
|
-
|
|
113453
|
+
const at = this.pointAt(e.clientX, e.clientY);
|
|
113454
|
+
diagram.centerOn({
|
|
113455
|
+
x: at.x - s.grab.x,
|
|
113456
|
+
y: at.y - s.grab.y
|
|
113457
|
+
});
|
|
113312
113458
|
}
|
|
113313
|
-
|
|
113314
|
-
|
|
113315
|
-
|
|
113316
|
-
|
|
113317
|
-
|
|
113318
|
-
this.
|
|
113319
|
-
const style = this.node.style ?? {};
|
|
113320
|
-
for (const name of this.drawnStyle) if (!(name in style)) css(this.part, name, "");
|
|
113321
|
-
for (const [name, value] of Object.entries(style)) css(this.part, name, value);
|
|
113322
|
-
this.drawnStyle = Object.keys(style);
|
|
113459
|
+
released(e) {
|
|
113460
|
+
const s = this.session;
|
|
113461
|
+
if (!s || e.pointerId !== s.pointerId) return;
|
|
113462
|
+
this.end();
|
|
113463
|
+
if (!s.moved && e.type === "pointerup") this.target?.centerOn(s.at, { animate: true });
|
|
113464
|
+
this.drawView();
|
|
113323
113465
|
}
|
|
113324
|
-
|
|
113325
|
-
|
|
113326
|
-
|
|
113327
|
-
|
|
113328
|
-
|
|
113329
|
-
removePart(this.statusMark);
|
|
113330
|
-
this.statusMark = null;
|
|
113331
|
-
put(this.part, "aria-description", null);
|
|
113332
|
-
return;
|
|
113333
|
-
}
|
|
113334
|
-
if (!this.statusMark) {
|
|
113335
|
-
this.statusMark = part(this.part, "span", "mx-glyph mx-diagram__status");
|
|
113336
|
-
put(this.statusMark, "aria-hidden", "true");
|
|
113337
|
-
}
|
|
113338
|
-
const said = statusWords(status, this.node.statusText);
|
|
113339
|
-
put(this.statusMark, "title", said);
|
|
113340
|
-
put(this.part, "aria-description", said);
|
|
113466
|
+
end() {
|
|
113467
|
+
for (const stop of this.stops.splice(0)) stop();
|
|
113468
|
+
this.session = null;
|
|
113469
|
+
this.held = false;
|
|
113470
|
+
mark(this, "data-dragging", false);
|
|
113341
113471
|
}
|
|
113342
|
-
/**
|
|
113343
|
-
|
|
113344
|
-
const
|
|
113345
|
-
|
|
113346
|
-
|
|
113347
|
-
|
|
113348
|
-
|
|
113349
|
-
|
|
113350
|
-
|
|
113351
|
-
|
|
113352
|
-
|
|
113353
|
-
|
|
113354
|
-
|
|
113355
|
-
|
|
113356
|
-
};
|
|
113357
|
-
this.portParts.set(key, entry);
|
|
113358
|
-
}
|
|
113359
|
-
put(entry.part, "data-port", port.id);
|
|
113360
|
-
put(entry.part, "data-side", side);
|
|
113361
|
-
put(entry.part, "data-direction", port.direction && port.direction !== "both" ? port.direction : null);
|
|
113362
|
-
put(entry.part, "title", port.label || null);
|
|
113363
|
-
css(entry.part, "--_at", `${this.offsetOf(port, side) * 100}%`);
|
|
113364
|
-
}
|
|
113365
|
-
for (const [key, entry] of this.portParts) {
|
|
113366
|
-
if (seen.has(key)) continue;
|
|
113367
|
-
this.portParts.delete(key);
|
|
113368
|
-
removePart(entry.part);
|
|
113369
|
-
}
|
|
113472
|
+
/** The wheel zooms the diagram around the point of it under the pointer. */
|
|
113473
|
+
wheel(e) {
|
|
113474
|
+
const diagram = this.target;
|
|
113475
|
+
if (!diagram || !this.isEnabled || !diagram.zoomable) return;
|
|
113476
|
+
e.preventDefault();
|
|
113477
|
+
const unit = e.deltaMode === 1 ? WHEEL_LINE$1 : e.deltaMode === 2 ? this.room.height : 1;
|
|
113478
|
+
const v = diagram.viewport;
|
|
113479
|
+
const zoom = Math.min(Math.max(v.zoom * Math.exp(-e.deltaY * unit * WHEEL_ZOOM$1), diagram.minZoom), diagram.maxZoom);
|
|
113480
|
+
const at = this.pointAt(e.clientX, e.clientY);
|
|
113481
|
+
diagram.setViewport({
|
|
113482
|
+
x: v.x + at.x * (v.zoom - zoom),
|
|
113483
|
+
y: v.y + at.y * (v.zoom - zoom),
|
|
113484
|
+
zoom
|
|
113485
|
+
});
|
|
113370
113486
|
}
|
|
113371
|
-
/** The
|
|
113372
|
-
|
|
113373
|
-
|
|
113374
|
-
|
|
113375
|
-
|
|
113487
|
+
/** The arrows show more of the diagram on their side; plus and minus zoom. */
|
|
113488
|
+
keyDown(e) {
|
|
113489
|
+
const diagram = this.target;
|
|
113490
|
+
if (!diagram || !this.isEnabled || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
113491
|
+
const v = diagram.viewport;
|
|
113492
|
+
const step = e.shiftKey ? 160 : KEY_STEP$1;
|
|
113493
|
+
const move = {
|
|
113494
|
+
ArrowLeft: [step, 0],
|
|
113495
|
+
ArrowRight: [-step, 0],
|
|
113496
|
+
ArrowUp: [0, step],
|
|
113497
|
+
ArrowDown: [0, -step]
|
|
113498
|
+
}[e.key];
|
|
113499
|
+
if (move) {
|
|
113500
|
+
if (!diagram.pannable) return;
|
|
113501
|
+
e.preventDefault();
|
|
113502
|
+
diagram.setViewport({
|
|
113503
|
+
x: v.x + move[0],
|
|
113504
|
+
y: v.y + move[1],
|
|
113505
|
+
zoom: v.zoom
|
|
113506
|
+
});
|
|
113376
113507
|
return;
|
|
113377
113508
|
}
|
|
113378
|
-
|
|
113379
|
-
|
|
113380
|
-
|
|
113381
|
-
|
|
113382
|
-
|
|
113383
|
-
|
|
113384
|
-
|
|
113385
|
-
this.resizers.set(side, p);
|
|
113509
|
+
if (!diagram.zoomable) return;
|
|
113510
|
+
if (e.key === "+" || e.key === "=") {
|
|
113511
|
+
e.preventDefault();
|
|
113512
|
+
diagram.zoomIn();
|
|
113513
|
+
} else if (e.key === "-" || e.key === "_") {
|
|
113514
|
+
e.preventDefault();
|
|
113515
|
+
diagram.zoomOut();
|
|
113386
113516
|
}
|
|
113387
113517
|
}
|
|
113388
113518
|
};
|
|
113519
|
+
function num$1(value) {
|
|
113520
|
+
return String(Math.round(value * 100) / 100);
|
|
113521
|
+
}
|
|
113389
113522
|
//#endregion
|
|
113390
113523
|
//#region src/components/diagram/DiagramOverview.ts
|
|
113391
113524
|
/**
|
|
@@ -113655,6 +113788,7 @@ var OWN$10 = [
|
|
|
113655
113788
|
"snapToGrid",
|
|
113656
113789
|
"guides",
|
|
113657
113790
|
"history",
|
|
113791
|
+
"textEditable",
|
|
113658
113792
|
"commandScope",
|
|
113659
113793
|
"minZoom",
|
|
113660
113794
|
"maxZoom",
|
|
@@ -113942,6 +114076,60 @@ var Diagram = class extends Control {
|
|
|
113942
114076
|
_defineProperty(this, "pastingEmitter", new Emitter());
|
|
113943
114077
|
_defineProperty(this, "pastedEmitter", new Emitter());
|
|
113944
114078
|
_defineProperty(this, "historyChangedEmitter", new Emitter());
|
|
114079
|
+
_defineProperty(this, "nodeClickEmitter", new Emitter());
|
|
114080
|
+
_defineProperty(this, "nodeDblClickEmitter", new Emitter());
|
|
114081
|
+
_defineProperty(this, "nodeMenuEmitter", new Emitter());
|
|
114082
|
+
_defineProperty(this, "nodeMenu", heard(this.nodeMenuEmitter));
|
|
114083
|
+
_defineProperty(this, "nodePointerEnterEmitter", new Emitter());
|
|
114084
|
+
_defineProperty(this, "nodePointerLeaveEmitter", new Emitter());
|
|
114085
|
+
_defineProperty(this, "edgeClickEmitter", new Emitter());
|
|
114086
|
+
_defineProperty(this, "edgeDblClickEmitter", new Emitter());
|
|
114087
|
+
_defineProperty(this, "edgeMenuEmitter", new Emitter());
|
|
114088
|
+
_defineProperty(this, "edgeMenu", heard(this.edgeMenuEmitter));
|
|
114089
|
+
_defineProperty(this, "edgePointerEnterEmitter", new Emitter());
|
|
114090
|
+
_defineProperty(this, "edgePointerLeaveEmitter", new Emitter());
|
|
114091
|
+
_defineProperty(this, "textEditingEmitter", new Emitter());
|
|
114092
|
+
_defineProperty(this, "textChangingEmitter", new Emitter());
|
|
114093
|
+
_defineProperty(this, "textChangedEmitter", new Emitter());
|
|
114094
|
+
_defineProperty(
|
|
114095
|
+
this,
|
|
114096
|
+
/** What every node's part asks of the diagram and tells it: one object for all the nodes, however many. */
|
|
114097
|
+
"nodeHost",
|
|
114098
|
+
{
|
|
114099
|
+
diagram: this,
|
|
114100
|
+
kindOf: (n) => this.kindOf(n),
|
|
114101
|
+
isSelected: (v) => this.chosen.nodes.has(v.node.id),
|
|
114102
|
+
estimate: (v) => this.estimate(v),
|
|
114103
|
+
sized: (v) => {
|
|
114104
|
+
this.noteSize(v);
|
|
114105
|
+
this.links.nodeChanged(v.node.id);
|
|
114106
|
+
this.sizedSince = true;
|
|
114107
|
+
this.askDraw();
|
|
114108
|
+
},
|
|
114109
|
+
pressed: (v, port, e, drags) => {
|
|
114110
|
+
if (this.panning.isSpaceHeld) return;
|
|
114111
|
+
if (port) {
|
|
114112
|
+
if (this.connectable && this.changeable && v.node.connectable !== false) this.links.startConnect(v, port, e);
|
|
114113
|
+
} else this.dragging.nodePressed(v, e, drags);
|
|
114114
|
+
},
|
|
114115
|
+
resizePressed: (v, side, e) => {
|
|
114116
|
+
if (!this.panning.isSpaceHeld) this.dragging.resizePressed(v, side, e);
|
|
114117
|
+
},
|
|
114118
|
+
told: (what, v, e) => this.nodeTold(what, v, e)
|
|
114119
|
+
}
|
|
114120
|
+
);
|
|
114121
|
+
_defineProperty(
|
|
114122
|
+
this,
|
|
114123
|
+
/** When the Menu key or Shift+F10 last opened the app's menu: the `contextmenu` event the browser sends after it stays its own. */
|
|
114124
|
+
"menuKeyAt",
|
|
114125
|
+
-Infinity
|
|
114126
|
+
);
|
|
114127
|
+
_defineProperty(
|
|
114128
|
+
this,
|
|
114129
|
+
/** The node whose text is edited in place, and its editor, while it is. */
|
|
114130
|
+
"editing",
|
|
114131
|
+
null
|
|
114132
|
+
);
|
|
113945
114133
|
_defineProperty(
|
|
113946
114134
|
this,
|
|
113947
114135
|
/** The size of the surface, from its size observer; 0 until it is laid out. */
|
|
@@ -114079,6 +114267,7 @@ var Diagram = class extends Control {
|
|
|
114079
114267
|
this.edgeReshapedEmitter.fire(e);
|
|
114080
114268
|
},
|
|
114081
114269
|
edgeClicked: (edge, e) => this.edgeClicked(edge, e),
|
|
114270
|
+
edgeTold: (what, edge, e) => this.edgeTold(what, edge, e),
|
|
114082
114271
|
askDraw: () => this.askDraw(),
|
|
114083
114272
|
nodesMoved: () => {
|
|
114084
114273
|
this.contentMoved = true;
|
|
@@ -114143,6 +114332,19 @@ var Diagram = class extends Control {
|
|
|
114143
114332
|
if (own.onPasted) this.onPasted(own.onPasted);
|
|
114144
114333
|
if (own.onHistoryChanged) this.onHistoryChanged(own.onHistoryChanged);
|
|
114145
114334
|
if (own.onContentChanged) this.onContentChanged(own.onContentChanged);
|
|
114335
|
+
if (own.onNodeClick) this.onNodeClick(own.onNodeClick);
|
|
114336
|
+
if (own.onNodeDblClick) this.onNodeDblClick(own.onNodeDblClick);
|
|
114337
|
+
if (own.onNodeContextMenu) this.onNodeContextMenu(own.onNodeContextMenu);
|
|
114338
|
+
if (own.onNodePointerEnter) this.onNodePointerEnter(own.onNodePointerEnter);
|
|
114339
|
+
if (own.onNodePointerLeave) this.onNodePointerLeave(own.onNodePointerLeave);
|
|
114340
|
+
if (own.onEdgeClick) this.onEdgeClick(own.onEdgeClick);
|
|
114341
|
+
if (own.onEdgeDblClick) this.onEdgeDblClick(own.onEdgeDblClick);
|
|
114342
|
+
if (own.onEdgeContextMenu) this.onEdgeContextMenu(own.onEdgeContextMenu);
|
|
114343
|
+
if (own.onEdgePointerEnter) this.onEdgePointerEnter(own.onEdgePointerEnter);
|
|
114344
|
+
if (own.onEdgePointerLeave) this.onEdgePointerLeave(own.onEdgePointerLeave);
|
|
114345
|
+
if (own.onTextEditing) this.onTextEditing(own.onTextEditing);
|
|
114346
|
+
if (own.onTextChanging) this.onTextChanging(own.onTextChanging);
|
|
114347
|
+
if (own.onTextChanged) this.onTextChanged(own.onTextChanged);
|
|
114146
114348
|
if (own.edges === void 0) this.changeProperty("edges", []);
|
|
114147
114349
|
this.toldViewport = this.viewport;
|
|
114148
114350
|
this.observeProperty("nodes", () => this.nodesChanged());
|
|
@@ -114163,6 +114365,7 @@ var Diagram = class extends Control {
|
|
|
114163
114365
|
this.stopKeyConnect();
|
|
114164
114366
|
this.stopKeyMove();
|
|
114165
114367
|
this.setKeyBend(null);
|
|
114368
|
+
this.stopEditing(false);
|
|
114166
114369
|
}
|
|
114167
114370
|
this.askDraw();
|
|
114168
114371
|
});
|
|
@@ -114210,7 +114413,13 @@ var Diagram = class extends Control {
|
|
|
114210
114413
|
]);
|
|
114211
114414
|
onLayout(this, "size", (size) => this.resized(size));
|
|
114212
114415
|
onLayout(this, "look", () => this.askDraw());
|
|
114416
|
+
this.motif.on("contextmenu", (_, e) => {
|
|
114417
|
+
if (performance.now() - this.menuKeyAt >= 1e3) return;
|
|
114418
|
+
this.menuKeyAt = -Infinity;
|
|
114419
|
+
e.preventDefault();
|
|
114420
|
+
});
|
|
114213
114421
|
this.motif.on("pointerdown", (_, e) => {
|
|
114422
|
+
this.menuKeyAt = -Infinity;
|
|
114214
114423
|
if (this.fromMap(e)) return;
|
|
114215
114424
|
if (!(this.nodeLayer.motif.isEventFrom(e) || this.handleLayer.motif.isEventFrom(e) || this.links.took(e)) && !this.panning.isSpaceHeld && this.dragging.surfacePressed(e)) return;
|
|
114216
114425
|
this.panning.pointerDown(e);
|
|
@@ -114235,6 +114444,7 @@ var Diagram = class extends Control {
|
|
|
114235
114444
|
this.nodeLayer.motif.on("focusout", () => this.commandState.typing = false);
|
|
114236
114445
|
this.motif.setDisposable(() => {
|
|
114237
114446
|
for (const stop of this.commandStops.splice(0)) stop();
|
|
114447
|
+
this.stopEditing(false);
|
|
114238
114448
|
this.finishLayout?.();
|
|
114239
114449
|
this.stopMotion();
|
|
114240
114450
|
this.panning.dispose();
|
|
@@ -114260,7 +114470,20 @@ var Diagram = class extends Control {
|
|
|
114260
114470
|
this.columnCheckedEmitter,
|
|
114261
114471
|
this.edgeReshapingEmitter,
|
|
114262
114472
|
this.edgeReshapedEmitter,
|
|
114263
|
-
this.contentChangedEmitter
|
|
114473
|
+
this.contentChangedEmitter,
|
|
114474
|
+
this.nodeClickEmitter,
|
|
114475
|
+
this.nodeDblClickEmitter,
|
|
114476
|
+
this.nodeMenuEmitter,
|
|
114477
|
+
this.nodePointerEnterEmitter,
|
|
114478
|
+
this.nodePointerLeaveEmitter,
|
|
114479
|
+
this.edgeClickEmitter,
|
|
114480
|
+
this.edgeDblClickEmitter,
|
|
114481
|
+
this.edgeMenuEmitter,
|
|
114482
|
+
this.edgePointerEnterEmitter,
|
|
114483
|
+
this.edgePointerLeaveEmitter,
|
|
114484
|
+
this.textEditingEmitter,
|
|
114485
|
+
this.textChangingEmitter,
|
|
114486
|
+
this.textChangedEmitter
|
|
114264
114487
|
]) emitter.dispose();
|
|
114265
114488
|
});
|
|
114266
114489
|
this.askDraw();
|
|
@@ -114341,6 +114564,12 @@ var Diagram = class extends Control {
|
|
|
114341
114564
|
set history(value) {
|
|
114342
114565
|
this.assignProperty("history", value);
|
|
114343
114566
|
}
|
|
114567
|
+
get textEditable() {
|
|
114568
|
+
return this.getProperty("textEditable") ?? false;
|
|
114569
|
+
}
|
|
114570
|
+
set textEditable(value) {
|
|
114571
|
+
this.assignProperty("textEditable", value);
|
|
114572
|
+
}
|
|
114344
114573
|
get commandScope() {
|
|
114345
114574
|
return this.getProperty("commandScope") ?? null;
|
|
114346
114575
|
}
|
|
@@ -114849,6 +115078,45 @@ var Diagram = class extends Control {
|
|
|
114849
115078
|
get onContentChanged() {
|
|
114850
115079
|
return this.contentChangedEmitter.event;
|
|
114851
115080
|
}
|
|
115081
|
+
get onNodeClick() {
|
|
115082
|
+
return this.nodeClickEmitter.event;
|
|
115083
|
+
}
|
|
115084
|
+
get onNodeDblClick() {
|
|
115085
|
+
return this.nodeDblClickEmitter.event;
|
|
115086
|
+
}
|
|
115087
|
+
get onNodeContextMenu() {
|
|
115088
|
+
return this.nodeMenu.event;
|
|
115089
|
+
}
|
|
115090
|
+
get onNodePointerEnter() {
|
|
115091
|
+
return this.nodePointerEnterEmitter.event;
|
|
115092
|
+
}
|
|
115093
|
+
get onNodePointerLeave() {
|
|
115094
|
+
return this.nodePointerLeaveEmitter.event;
|
|
115095
|
+
}
|
|
115096
|
+
get onEdgeClick() {
|
|
115097
|
+
return this.edgeClickEmitter.event;
|
|
115098
|
+
}
|
|
115099
|
+
get onEdgeDblClick() {
|
|
115100
|
+
return this.edgeDblClickEmitter.event;
|
|
115101
|
+
}
|
|
115102
|
+
get onEdgeContextMenu() {
|
|
115103
|
+
return this.edgeMenu.event;
|
|
115104
|
+
}
|
|
115105
|
+
get onEdgePointerEnter() {
|
|
115106
|
+
return this.edgePointerEnterEmitter.event;
|
|
115107
|
+
}
|
|
115108
|
+
get onEdgePointerLeave() {
|
|
115109
|
+
return this.edgePointerLeaveEmitter.event;
|
|
115110
|
+
}
|
|
115111
|
+
get onTextEditing() {
|
|
115112
|
+
return this.textEditingEmitter.event;
|
|
115113
|
+
}
|
|
115114
|
+
get onTextChanging() {
|
|
115115
|
+
return this.textChangingEmitter.event;
|
|
115116
|
+
}
|
|
115117
|
+
get onTextChanged() {
|
|
115118
|
+
return this.textChangedEmitter.event;
|
|
115119
|
+
}
|
|
114852
115120
|
/** Makes the selection these nodes and connections, the ones that exist and may be selected; tells when it changed. */
|
|
114853
115121
|
choose(nodes, edges, byUser) {
|
|
114854
115122
|
const nodeIds = /* @__PURE__ */ new Set();
|
|
@@ -114879,11 +115147,231 @@ var Diagram = class extends Control {
|
|
|
114879
115147
|
});
|
|
114880
115148
|
}
|
|
114881
115149
|
edgeClicked(edge, e) {
|
|
114882
|
-
if (!this.
|
|
115150
|
+
if (!this.isEnabled) return;
|
|
115151
|
+
const args = this.edgeArgs(edge, e, false);
|
|
115152
|
+
this.edgeClickEmitter.fire(args);
|
|
115153
|
+
if (args.cancel || !this.selectable || edge.selectable === false) return;
|
|
114883
115154
|
if (!(e.shiftKey || e.ctrlKey || e.metaKey)) this.choose([], [edge.id], true);
|
|
114884
115155
|
else if (this.chosen.edges.has(edge.id)) this.choose(this.chosen.nodes, [...this.chosen.edges].filter((id) => id !== edge.id), true);
|
|
114885
115156
|
else this.choose(this.chosen.nodes, [...this.chosen.edges, edge.id], true);
|
|
114886
115157
|
}
|
|
115158
|
+
/** What the pointer did on a node: told; a double click on its text edits it, a right click opens the app's menu. */
|
|
115159
|
+
nodeTold(what, view, e) {
|
|
115160
|
+
if (!this.isEnabled) return;
|
|
115161
|
+
if (what === "click") this.nodeClickEmitter.fire(this.nodeArgs(view, e, false));
|
|
115162
|
+
else if (what === "dblclick") this.nodeOpened(view, e, false, view.isTextEvent(e));
|
|
115163
|
+
else if (what === "contextmenu") this.nodeMenuAsked(view, e, false);
|
|
115164
|
+
else (what === "enter" ? this.nodePointerEnterEmitter : this.nodePointerLeaveEmitter).fire({
|
|
115165
|
+
node: view.node,
|
|
115166
|
+
event: e
|
|
115167
|
+
});
|
|
115168
|
+
}
|
|
115169
|
+
/** What the pointer did on a connection, besides a click: told; a right click opens the app's menu. */
|
|
115170
|
+
edgeTold(what, edge, e) {
|
|
115171
|
+
if (!this.isEnabled) return;
|
|
115172
|
+
if (what === "dblclick") this.edgeDblClickEmitter.fire(this.edgeArgs(edge, e, false));
|
|
115173
|
+
else if (what === "contextmenu") this.edgeMenuAsked(edge, e, false);
|
|
115174
|
+
else (what === "enter" ? this.edgePointerEnterEmitter : this.edgePointerLeaveEmitter).fire({
|
|
115175
|
+
edge,
|
|
115176
|
+
event: e
|
|
115177
|
+
});
|
|
115178
|
+
}
|
|
115179
|
+
/** What a click on a node tells: where it was on the page, or for a key the middle of the node. */
|
|
115180
|
+
nodeArgs(view, e, byKeyboard) {
|
|
115181
|
+
const r = view.rect;
|
|
115182
|
+
const at = !byKeyboard && "clientX" in e ? {
|
|
115183
|
+
x: e.clientX,
|
|
115184
|
+
y: e.clientY
|
|
115185
|
+
} : this.toClient({
|
|
115186
|
+
x: r.x + r.width / 2,
|
|
115187
|
+
y: r.y + r.height / 2
|
|
115188
|
+
});
|
|
115189
|
+
return {
|
|
115190
|
+
node: view.node,
|
|
115191
|
+
event: e,
|
|
115192
|
+
byKeyboard,
|
|
115193
|
+
at,
|
|
115194
|
+
cancel: false
|
|
115195
|
+
};
|
|
115196
|
+
}
|
|
115197
|
+
/** What a click on a connection tells: where it was on the page, or for a key the middle between its ends. */
|
|
115198
|
+
edgeArgs(edge, e, byKeyboard) {
|
|
115199
|
+
let at;
|
|
115200
|
+
const ends = this.links.lineOf(edge.id)?.ends;
|
|
115201
|
+
if (!byKeyboard && "clientX" in e) at = {
|
|
115202
|
+
x: e.clientX,
|
|
115203
|
+
y: e.clientY
|
|
115204
|
+
};
|
|
115205
|
+
else if (ends) at = this.toClient({
|
|
115206
|
+
x: (ends.source.x + ends.target.x) / 2,
|
|
115207
|
+
y: (ends.source.y + ends.target.y) / 2
|
|
115208
|
+
});
|
|
115209
|
+
else at = this.toClientOfSurface(this.middle());
|
|
115210
|
+
return {
|
|
115211
|
+
edge,
|
|
115212
|
+
event: e,
|
|
115213
|
+
byKeyboard,
|
|
115214
|
+
at,
|
|
115215
|
+
cancel: false
|
|
115216
|
+
};
|
|
115217
|
+
}
|
|
115218
|
+
/** A double click on a node, or Alt+Enter on it: told, then its text is edited (`textEditable`), unless canceled. */
|
|
115219
|
+
nodeOpened(view, e, byKeyboard, onText) {
|
|
115220
|
+
const args = this.nodeArgs(view, e, byKeyboard);
|
|
115221
|
+
this.nodeDblClickEmitter.fire(args);
|
|
115222
|
+
if (!args.cancel && onText && this.textEditable) this.startEditing(view, byKeyboard);
|
|
115223
|
+
}
|
|
115224
|
+
/**
|
|
115225
|
+
* A right click on a node, or the Menu key on it: told to the app, which opens its menu there; the browser's own
|
|
115226
|
+
* stays closed, unless canceled. Nothing is told while nobody listens. Returns whether the app took it.
|
|
115227
|
+
*/
|
|
115228
|
+
nodeMenuAsked(view, e, byKeyboard) {
|
|
115229
|
+
if (!this.nodeMenu.heard()) return false;
|
|
115230
|
+
const args = this.nodeArgs(view, e, byKeyboard);
|
|
115231
|
+
this.nodeMenuEmitter.fire(args);
|
|
115232
|
+
if (args.cancel) return false;
|
|
115233
|
+
e.preventDefault();
|
|
115234
|
+
return true;
|
|
115235
|
+
}
|
|
115236
|
+
/** A right click on a connection, or the Menu key on it, as `nodeMenuAsked`. */
|
|
115237
|
+
edgeMenuAsked(edge, e, byKeyboard) {
|
|
115238
|
+
if (!this.edgeMenu.heard()) return false;
|
|
115239
|
+
const args = this.edgeArgs(edge, e, byKeyboard);
|
|
115240
|
+
this.edgeMenuEmitter.fire(args);
|
|
115241
|
+
if (args.cancel) return false;
|
|
115242
|
+
e.preventDefault();
|
|
115243
|
+
return true;
|
|
115244
|
+
}
|
|
115245
|
+
/** The Menu key or Shift+F10: the context menu of the connection or the node under the keys. Returns whether the app took it. */
|
|
115246
|
+
keyMenu(e) {
|
|
115247
|
+
const line = this.lineUnderKeys();
|
|
115248
|
+
if (line) return this.edgeMenuAsked(line.edge, e, true);
|
|
115249
|
+
const view = this.active ? this.views.get(this.active) : void 0;
|
|
115250
|
+
return !!view && this.nodeMenuAsked(view, e, true);
|
|
115251
|
+
}
|
|
115252
|
+
/** Alt+Enter: a double click on the connection or the node under the keys. Returns whether there was one. */
|
|
115253
|
+
keyOpen(e) {
|
|
115254
|
+
const line = this.lineUnderKeys();
|
|
115255
|
+
if (line) {
|
|
115256
|
+
this.edgeDblClickEmitter.fire(this.edgeArgs(line.edge, e, true));
|
|
115257
|
+
return true;
|
|
115258
|
+
}
|
|
115259
|
+
const view = this.active ? this.views.get(this.active) : void 0;
|
|
115260
|
+
if (!view) return false;
|
|
115261
|
+
this.nodeOpened(view, e, true, true);
|
|
115262
|
+
return true;
|
|
115263
|
+
}
|
|
115264
|
+
/** What a screen reader calls a connection: its label, else its two nodes. */
|
|
115265
|
+
edgeName(edge) {
|
|
115266
|
+
if (edge.label) return edge.label;
|
|
115267
|
+
const name = (id) => this.views.get(id)?.name ?? id;
|
|
115268
|
+
return uiLocale.text("diagramEdgeName", {
|
|
115269
|
+
source: name(edge.source),
|
|
115270
|
+
target: name(edge.target)
|
|
115271
|
+
});
|
|
115272
|
+
}
|
|
115273
|
+
/** The node F2 and the `rename` command edit the text of: the one under the keys, else the only one selected. */
|
|
115274
|
+
renameTarget() {
|
|
115275
|
+
const id = this.active ?? (this.chosen.nodes.size === 1 && !this.chosen.edges.size ? [...this.chosen.nodes][0] : null);
|
|
115276
|
+
return id ? this.views.get(id) : void 0;
|
|
115277
|
+
}
|
|
115278
|
+
/** Opens the editor of a node's text over it, after `onTextEditing`; an edit going on elsewhere is written first. */
|
|
115279
|
+
startEditing(view, byKeyboard) {
|
|
115280
|
+
if (this.readOnly || !this.isEnabled || !view.live || !view.entered || view.hidden) return false;
|
|
115281
|
+
if (this.editing?.view === view) return true;
|
|
115282
|
+
const args = {
|
|
115283
|
+
node: view.node,
|
|
115284
|
+
text: view.node.text ?? "",
|
|
115285
|
+
byKeyboard,
|
|
115286
|
+
cancel: false
|
|
115287
|
+
};
|
|
115288
|
+
this.textEditingEmitter.fire(args);
|
|
115289
|
+
if (args.cancel) return false;
|
|
115290
|
+
this.stopEditing(true);
|
|
115291
|
+
this.choose([view.node.id], [], true);
|
|
115292
|
+
this.setActive(view.node.id, false);
|
|
115293
|
+
this.reveal(view);
|
|
115294
|
+
const editor = new TextBox({
|
|
115295
|
+
value: args.text,
|
|
115296
|
+
label: uiLocale.text("diagramTextEditor", { name: view.name }),
|
|
115297
|
+
labelMode: "hidden",
|
|
115298
|
+
size: "sm",
|
|
115299
|
+
selectOnFocus: true,
|
|
115300
|
+
updateOn: "input"
|
|
115301
|
+
});
|
|
115302
|
+
editor.class.add("mx-diagram__text-editor");
|
|
115303
|
+
editor.onEnter(() => this.stopEditing(true));
|
|
115304
|
+
editor.motif.on("keydown", (_, e) => {
|
|
115305
|
+
if (e.key !== "Escape") return;
|
|
115306
|
+
this.stopEditing(false);
|
|
115307
|
+
return { cancel: true };
|
|
115308
|
+
});
|
|
115309
|
+
editor.motif.on("focusout", () => {
|
|
115310
|
+
queueMicrotask(() => {
|
|
115311
|
+
if (this.editing?.editor === editor && !holdsFocus(editor)) this.stopEditing(true);
|
|
115312
|
+
});
|
|
115313
|
+
});
|
|
115314
|
+
this.editing = {
|
|
115315
|
+
view,
|
|
115316
|
+
editor
|
|
115317
|
+
};
|
|
115318
|
+
view.holdEditor(editor);
|
|
115319
|
+
editor.focus();
|
|
115320
|
+
return true;
|
|
115321
|
+
}
|
|
115322
|
+
/**
|
|
115323
|
+
* Ends the edit of a node's text: `write` writes the editor's text, after `onTextChanging`, as a step of the history.
|
|
115324
|
+
* The editor goes; when it had focus, focus comes back to the diagram, on the node.
|
|
115325
|
+
*/
|
|
115326
|
+
stopEditing(write) {
|
|
115327
|
+
const now = this.editing;
|
|
115328
|
+
if (!now) return;
|
|
115329
|
+
this.editing = null;
|
|
115330
|
+
const { view, editor } = now;
|
|
115331
|
+
const typed = editor.value ?? "";
|
|
115332
|
+
const hadFocus = holdsFocus(editor);
|
|
115333
|
+
view.holdEditor(null);
|
|
115334
|
+
if (write) this.writeText(view, typed);
|
|
115335
|
+
if (!hadFocus || this.isDisposed) return;
|
|
115336
|
+
this.focus();
|
|
115337
|
+
this.setActive(view.node.id, true);
|
|
115338
|
+
}
|
|
115339
|
+
/** Writes a node's new text, after `onTextChanging`, as a step of the history, and tells it. */
|
|
115340
|
+
writeText(view, typed) {
|
|
115341
|
+
const node = view.node;
|
|
115342
|
+
const before = node.text;
|
|
115343
|
+
const previous = before ?? "";
|
|
115344
|
+
if (typed === previous) return;
|
|
115345
|
+
const args = {
|
|
115346
|
+
node,
|
|
115347
|
+
text: typed,
|
|
115348
|
+
previous,
|
|
115349
|
+
cancel: false
|
|
115350
|
+
};
|
|
115351
|
+
this.textChangingEmitter.fire(args);
|
|
115352
|
+
if (args.cancel || args.text === previous) return;
|
|
115353
|
+
const after = args.text;
|
|
115354
|
+
const set = (value) => {
|
|
115355
|
+
if (value === void 0) delete node.text;
|
|
115356
|
+
else node.text = value;
|
|
115357
|
+
this.views.get(node.id)?.draw();
|
|
115358
|
+
};
|
|
115359
|
+
set(after);
|
|
115360
|
+
this.addStep({
|
|
115361
|
+
undo: () => set(before),
|
|
115362
|
+
redo: () => set(after),
|
|
115363
|
+
change: {
|
|
115364
|
+
kind: "text",
|
|
115365
|
+
nodes: [node],
|
|
115366
|
+
edges: []
|
|
115367
|
+
}
|
|
115368
|
+
});
|
|
115369
|
+
this.textChangedEmitter.fire({
|
|
115370
|
+
node,
|
|
115371
|
+
text: after,
|
|
115372
|
+
previous
|
|
115373
|
+
});
|
|
115374
|
+
}
|
|
114887
115375
|
canMove(view) {
|
|
114888
115376
|
return this.draggable && this.changeable && view.node.draggable !== false;
|
|
114889
115377
|
}
|
|
@@ -115627,6 +116115,10 @@ var Diagram = class extends Control {
|
|
|
115627
116115
|
make("duplicate", "diagramDuplicate", () => this.duplicate(), () => s.nodesSelected > 0 && changes(), "Mod+D"),
|
|
115628
116116
|
make("delete", "diagramDelete", () => this.dropBend() || this.deleteChosen(true), () => changes() && (s.selected && this.deletable || !!this.bendUnderKeys()), ["Delete", "Backspace"]),
|
|
115629
116117
|
make("selectAll", "diagramSelectAll", () => this.chooseAll(), () => this.selectable, "Mod+A"),
|
|
116118
|
+
make("rename", "diagramRename", () => {
|
|
116119
|
+
const view = this.renameTarget();
|
|
116120
|
+
if (view) this.startEditing(view, true);
|
|
116121
|
+
}, () => this.textEditable && changes() && (s.nodesSelected === 1 || !!this.active), "F2"),
|
|
115630
116122
|
make("zoomIn", "diagramZoomIn", () => this.zoomIn({ animate: true }), () => this.zoomable),
|
|
115631
116123
|
make("zoomOut", "diagramZoomOut", () => this.zoomOut({ animate: true }), () => this.zoomable),
|
|
115632
116124
|
make("zoomToFit", "diagramFit", () => this.fit({ animate: true })),
|
|
@@ -115744,27 +116236,7 @@ var Diagram = class extends Control {
|
|
|
115744
116236
|
seen.add(node.id);
|
|
115745
116237
|
let view = this.views.get(node.id);
|
|
115746
116238
|
if (!view) {
|
|
115747
|
-
view = new DiagramNodeView(node,
|
|
115748
|
-
diagram: this,
|
|
115749
|
-
kindOf: (n) => this.kindOf(n),
|
|
115750
|
-
isSelected: (v) => this.chosen.nodes.has(v.node.id),
|
|
115751
|
-
estimate: (v) => this.estimate(v),
|
|
115752
|
-
sized: (v) => {
|
|
115753
|
-
this.noteSize(v);
|
|
115754
|
-
this.links.nodeChanged(v.node.id);
|
|
115755
|
-
this.sizedSince = true;
|
|
115756
|
-
this.askDraw();
|
|
115757
|
-
},
|
|
115758
|
-
pressed: (v, port, e, drags) => {
|
|
115759
|
-
if (this.panning.isSpaceHeld) return;
|
|
115760
|
-
if (port) {
|
|
115761
|
-
if (this.connectable && this.changeable && v.node.connectable !== false) this.links.startConnect(v, port, e);
|
|
115762
|
-
} else this.dragging.nodePressed(v, e, drags);
|
|
115763
|
-
},
|
|
115764
|
-
resizePressed: (v, side, e) => {
|
|
115765
|
-
if (!this.panning.isSpaceHeld) this.dragging.resizePressed(v, side, e);
|
|
115766
|
-
}
|
|
115767
|
-
});
|
|
116239
|
+
view = new DiagramNodeView(node, this.nodeHost);
|
|
115768
116240
|
this.views.set(node.id, view);
|
|
115769
116241
|
if (this.lazy) view.live = false;
|
|
115770
116242
|
else view.enter();
|
|
@@ -115777,6 +116249,7 @@ var Diagram = class extends Control {
|
|
|
115777
116249
|
}
|
|
115778
116250
|
for (const [id, view] of this.views) {
|
|
115779
116251
|
if (seen.has(id)) continue;
|
|
116252
|
+
if (this.editing?.view === view) this.stopEditing(false);
|
|
115780
116253
|
this.views.delete(id);
|
|
115781
116254
|
removePart(view.part);
|
|
115782
116255
|
}
|
|
@@ -116161,6 +116634,39 @@ var Diagram = class extends Control {
|
|
|
116161
116634
|
return true;
|
|
116162
116635
|
}
|
|
116163
116636
|
/**
|
|
116637
|
+
* Shows what a connection is doing as a run goes along it (`null` takes the status away): the look's color of the
|
|
116638
|
+
* status on its line and its marks, unless it has a `color` of its own, a line that moves while it runs, and the
|
|
116639
|
+
* status in the line's tip; a screen reader hears it with the connection's two nodes. Not a step of the history: the
|
|
116640
|
+
* connection's `status` and `statusText` are written, and saved with it unless the app leaves them out. Returns
|
|
116641
|
+
* whether it changed.
|
|
116642
|
+
*/
|
|
116643
|
+
setEdgeStatus(id, status, text) {
|
|
116644
|
+
const line = this.links.lineOf(id);
|
|
116645
|
+
if (!line) return false;
|
|
116646
|
+
const edge = line.edge;
|
|
116647
|
+
if ((edge.status ?? null) === status && (edge.statusText || void 0) === (status ? text || void 0 : void 0)) return false;
|
|
116648
|
+
if (status) edge.status = status;
|
|
116649
|
+
else delete edge.status;
|
|
116650
|
+
if (status && text) edge.statusText = text;
|
|
116651
|
+
else delete edge.statusText;
|
|
116652
|
+
line.drawState();
|
|
116653
|
+
if (status) this.announce(uiLocale.text("diagramStatusSaid", {
|
|
116654
|
+
name: this.edgeName(edge),
|
|
116655
|
+
status: statusWords(status, edge.statusText)
|
|
116656
|
+
}));
|
|
116657
|
+
return true;
|
|
116658
|
+
}
|
|
116659
|
+
/**
|
|
116660
|
+
* Edits a node's text in place, as a double click on it does with `textEditable`: an editor opens over the text, and
|
|
116661
|
+
* Enter or leaving it writes the new text as a step of the history, Escape keeps the old one. The node is selected
|
|
116662
|
+
* and brought into view. Returns whether the editor opened: not in a read-only diagram, not for a node off the page
|
|
116663
|
+
* (out of view in a large diagram, or in a collapsed group), and not when `onTextEditing` cancels.
|
|
116664
|
+
*/
|
|
116665
|
+
editText(id) {
|
|
116666
|
+
const view = this.views.get(id);
|
|
116667
|
+
return !!view && this.startEditing(view, false);
|
|
116668
|
+
}
|
|
116669
|
+
/**
|
|
116164
116670
|
* The connections of a node: those that end at it (`direction: 'in'`), start at it (`'out'`) or either, at one of its
|
|
116165
116671
|
* ports or any. Read in a getter, it follows the connections as they are drawn, taken away and moved.
|
|
116166
116672
|
*/
|
|
@@ -116610,6 +117116,14 @@ var Diagram = class extends Control {
|
|
|
116610
117116
|
}
|
|
116611
117117
|
keyDown(e) {
|
|
116612
117118
|
if (!this.isEnabled || this.nodeLayer.motif.isEventFrom(e) || this.fromMap(e)) return;
|
|
117119
|
+
if (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
|
117120
|
+
if (!this.connectingFrom && !this.keyMove && this.keyMenu(e)) this.menuKeyAt = performance.now();
|
|
117121
|
+
return;
|
|
117122
|
+
}
|
|
117123
|
+
if (e.key === "Enter" && e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
|
|
117124
|
+
if (!this.connectingFrom && !this.keyMove && this.keyOpen(e)) e.preventDefault();
|
|
117125
|
+
return;
|
|
117126
|
+
}
|
|
116613
117127
|
if ((e.key === "]" || e.key === "[") && !e.metaKey && (e.getModifierState("AltGraph") || !e.ctrlKey && !e.altKey)) {
|
|
116614
117128
|
if (!this.connectingFrom && !this.keyMove && this.walkLines(e.key === "]" ? 1 : -1)) e.preventDefault();
|
|
116615
117129
|
return;
|
|
@@ -116716,6 +117230,31 @@ var Diagram = class extends Control {
|
|
|
116716
117230
|
this.moveView(next, true);
|
|
116717
117231
|
}
|
|
116718
117232
|
};
|
|
117233
|
+
/**
|
|
117234
|
+
* The event of an emitter that counts its listeners: the diagram keeps the browser's context menu closed only for an
|
|
117235
|
+
* app that listens to the diagram's own.
|
|
117236
|
+
*/
|
|
117237
|
+
function heard(emitter) {
|
|
117238
|
+
let count = 0;
|
|
117239
|
+
const event = (listener, thisArgs, disposables) => {
|
|
117240
|
+
const own = emitter.event(listener, thisArgs);
|
|
117241
|
+
count++;
|
|
117242
|
+
let gone = false;
|
|
117243
|
+
const subscription = { dispose: () => {
|
|
117244
|
+
if (gone) return;
|
|
117245
|
+
gone = true;
|
|
117246
|
+
count--;
|
|
117247
|
+
own.dispose();
|
|
117248
|
+
} };
|
|
117249
|
+
if (Array.isArray(disposables)) disposables.push(subscription);
|
|
117250
|
+
else disposables?.add(subscription);
|
|
117251
|
+
return subscription;
|
|
117252
|
+
};
|
|
117253
|
+
return {
|
|
117254
|
+
event,
|
|
117255
|
+
heard: () => count > 0
|
|
117256
|
+
};
|
|
117257
|
+
}
|
|
116719
117258
|
function clamp(value, low, high) {
|
|
116720
117259
|
return Math.min(Math.max(value, low), high);
|
|
116721
117260
|
}
|