data-navigator 2.4.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-7YO7HC2V.js +1 -0
- package/dist/chunk-EXUS2ZKK.js +1 -0
- package/dist/chunk-UNB4R2QN.js +1 -0
- package/dist/chunk-UZ7O3OBE.js +1 -0
- package/dist/chunk-XOJI42HR.js +1 -0
- package/dist/chunk-YWWPZKYP.js +1 -0
- package/dist/consts.cjs +1 -1
- package/dist/consts.js +1 -1
- package/dist/index.cjs +419 -19
- package/dist/index.d.cts +103 -2
- package/dist/index.d.ts +103 -2
- package/dist/index.js +406 -19
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/rendering.cjs +1 -1
- package/dist/rendering.js +1 -1
- package/dist/structure.cjs +1 -1
- package/dist/structure.js +1 -1
- package/dist/text-chat.cjs +10 -10
- package/dist/text-chat.js +1 -1
- package/dist/utilities.cjs +1 -1
- package/dist/utilities.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,6 +17,28 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __accessCheck = (obj, member, msg) => {
|
|
21
|
+
if (!member.has(obj))
|
|
22
|
+
throw TypeError("Cannot " + msg);
|
|
23
|
+
};
|
|
24
|
+
var __privateGet = (obj, member, getter) => {
|
|
25
|
+
__accessCheck(obj, member, "read from private field");
|
|
26
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
27
|
+
};
|
|
28
|
+
var __privateAdd = (obj, member, value) => {
|
|
29
|
+
if (member.has(obj))
|
|
30
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
31
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
32
|
+
};
|
|
33
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
34
|
+
__accessCheck(obj, member, "write to private field");
|
|
35
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
38
|
+
var __privateMethod = (obj, member, method) => {
|
|
39
|
+
__accessCheck(obj, member, "access private method");
|
|
40
|
+
return method;
|
|
41
|
+
};
|
|
20
42
|
var __async = (__this, __arguments, generator) => {
|
|
21
43
|
return new Promise((resolve, reject) => {
|
|
22
44
|
var fulfilled = (value) => {
|
|
@@ -55,8 +77,8 @@ var defaultKeyBindings = {
|
|
|
55
77
|
ArrowDown: "down",
|
|
56
78
|
Period: "forward",
|
|
57
79
|
Comma: "backward",
|
|
58
|
-
Escape: "
|
|
59
|
-
Enter: "
|
|
80
|
+
Escape: "drill-out",
|
|
81
|
+
Enter: "drill-in"
|
|
60
82
|
};
|
|
61
83
|
var TypicallyUnreservedKeys = ["KeyW", "KeyJ", "LeftBracket", "RightBracket", "Slash", "Backslash"];
|
|
62
84
|
var TypicallyUnreservedKeyPairs = [
|
|
@@ -80,11 +102,11 @@ var GenericFullNavigationRules = {
|
|
|
80
102
|
key: "ArrowDown",
|
|
81
103
|
direction: "target"
|
|
82
104
|
},
|
|
83
|
-
|
|
105
|
+
"drill-in": {
|
|
84
106
|
key: "Enter",
|
|
85
107
|
direction: "target"
|
|
86
108
|
},
|
|
87
|
-
|
|
109
|
+
"drill-out": {
|
|
88
110
|
key: "Backspace",
|
|
89
111
|
direction: "source"
|
|
90
112
|
},
|
|
@@ -140,11 +162,11 @@ var GenericLimitedNavigationRules = {
|
|
|
140
162
|
key: "ArrowUp",
|
|
141
163
|
direction: "source"
|
|
142
164
|
},
|
|
143
|
-
|
|
165
|
+
"drill-in": {
|
|
144
166
|
key: "Enter",
|
|
145
167
|
direction: "target"
|
|
146
168
|
},
|
|
147
|
-
|
|
169
|
+
"drill-out": {
|
|
148
170
|
key: "Backspace",
|
|
149
171
|
direction: "source"
|
|
150
172
|
},
|
|
@@ -187,6 +209,26 @@ var NodeElementDefaults = {
|
|
|
187
209
|
spatialProperties: void 0
|
|
188
210
|
}
|
|
189
211
|
};
|
|
212
|
+
var GenericNavigationRuleCommands = {
|
|
213
|
+
"drill-in": { label: "Enter", description: "Drill in" },
|
|
214
|
+
"drill-out": { label: "Backspace", description: "Drill out" },
|
|
215
|
+
exit: { label: "Esc", description: "Exit" },
|
|
216
|
+
left: { label: "\u2190", description: "Previous data point" },
|
|
217
|
+
right: { label: "\u2192", description: "Next data point" },
|
|
218
|
+
up: { label: "\u2191", description: "Previous data point" },
|
|
219
|
+
down: { label: "\u2193", description: "Next data point" },
|
|
220
|
+
backward: { label: ",", description: "Move backward" },
|
|
221
|
+
forward: { label: ".", description: "Move forward" },
|
|
222
|
+
previous: { label: ";", description: "Previous" },
|
|
223
|
+
next: { label: "'", description: "Next" },
|
|
224
|
+
undo: { label: "Z", description: "Undo" },
|
|
225
|
+
help: { label: "Y", description: "Help" },
|
|
226
|
+
legend: { label: "L", description: "Legend" }
|
|
227
|
+
};
|
|
228
|
+
var commandsTableDefaultColumns = [
|
|
229
|
+
{ label: "Command", id: "description" },
|
|
230
|
+
{ label: "Key", id: "label" }
|
|
231
|
+
];
|
|
190
232
|
|
|
191
233
|
// src/utilities.ts
|
|
192
234
|
var describeNode = (d, descriptionOptions) => {
|
|
@@ -201,6 +243,12 @@ var describeNode = (d, descriptionOptions) => {
|
|
|
201
243
|
var createValidId = (s) => {
|
|
202
244
|
return "_" + s.replace(/[^a-zA-Z0-9_-]+/g, "_");
|
|
203
245
|
};
|
|
246
|
+
function getGenericCommandsFromNavRules(navigationRules) {
|
|
247
|
+
if (!navigationRules) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
return Object.keys(navigationRules).map((navId) => GenericNavigationRuleCommands[navId]).filter(Boolean);
|
|
251
|
+
}
|
|
204
252
|
|
|
205
253
|
// src/structure.ts
|
|
206
254
|
var structure_default = (options) => {
|
|
@@ -277,7 +325,7 @@ var buildNodeStructureFromVegaLite = (options) => {
|
|
|
277
325
|
edges[firstChildEdge] = {
|
|
278
326
|
source: node.id,
|
|
279
327
|
target: firstChildId,
|
|
280
|
-
navigationRules: ["
|
|
328
|
+
navigationRules: ["drill-out", "drill-in"]
|
|
281
329
|
};
|
|
282
330
|
}
|
|
283
331
|
}
|
|
@@ -290,7 +338,7 @@ var buildNodeStructureFromVegaLite = (options) => {
|
|
|
290
338
|
edges[parentEdge] = {
|
|
291
339
|
source: parentId,
|
|
292
340
|
target: node.id,
|
|
293
|
-
navigationRules: ["
|
|
341
|
+
navigationRules: ["drill-out", "drill-in"]
|
|
294
342
|
};
|
|
295
343
|
}
|
|
296
344
|
}
|
|
@@ -491,7 +539,7 @@ var scaffoldDimensions = (options, nodes) => {
|
|
|
491
539
|
},
|
|
492
540
|
navigationRules: dim.navigationRules || {
|
|
493
541
|
sibling_sibling: rules.length ? [...rules.shift()] : ["previous_" + dim.dimensionKey, "next_" + dim.dimensionKey],
|
|
494
|
-
parent_child: ["
|
|
542
|
+
parent_child: ["drill-out_" + dim.dimensionKey, "drill-in"]
|
|
495
543
|
}
|
|
496
544
|
};
|
|
497
545
|
nodes[id2] = {
|
|
@@ -721,7 +769,7 @@ var buildEdges = (options, nodes, dimensions) => {
|
|
|
721
769
|
let po = ((_d = options.dimensions) == null ? void 0 : _d.parentOptions) || {};
|
|
722
770
|
let extents = ((_f = (_e = po.level1Options) == null ? void 0 : _e.behavior) == null ? void 0 : _f.extents) || "terminal";
|
|
723
771
|
let level0 = po.addLevel0;
|
|
724
|
-
let parentRules = level0 ? ((_h = (_g = po.level1Options) == null ? void 0 : _g.navigationRules) == null ? void 0 : _h.parent_child) || ["
|
|
772
|
+
let parentRules = level0 ? ((_h = (_g = po.level1Options) == null ? void 0 : _g.navigationRules) == null ? void 0 : _h.parent_child) || ["drill-out", "drill-in"] : [];
|
|
725
773
|
let siblingRules = ((_j = (_i = po.level1Options) == null ? void 0 : _i.navigationRules) == null ? void 0 : _j.sibling_sibling) || ["left", "right"];
|
|
726
774
|
let firstLevel1Node = typeof order[0] === "string" ? hasOrder ? nodes[order[0]] : nodes[dimensions[order[0]].nodeId] : order[0];
|
|
727
775
|
if (level0) {
|
|
@@ -1033,8 +1081,8 @@ var buildRules = (options, edges, dimensions) => {
|
|
|
1033
1081
|
if (dimKeys.length) {
|
|
1034
1082
|
if ((_b = (_a = options.dimensions) == null ? void 0 : _a.parentOptions) == null ? void 0 : _b.addLevel0) {
|
|
1035
1083
|
let rules2 = ((_d = (_c = options.dimensions.parentOptions.level1Options) == null ? void 0 : _c.navigationRules) == null ? void 0 : _d.parent_child) || [
|
|
1036
|
-
"
|
|
1037
|
-
"
|
|
1084
|
+
"drill-out",
|
|
1085
|
+
"drill-in"
|
|
1038
1086
|
];
|
|
1039
1087
|
checkKeys(rules2[0], rules2[1]);
|
|
1040
1088
|
}
|
|
@@ -1190,6 +1238,124 @@ var input_default = (options) => {
|
|
|
1190
1238
|
return inputHandler;
|
|
1191
1239
|
};
|
|
1192
1240
|
|
|
1241
|
+
// src/commands-table.ts
|
|
1242
|
+
var _commands, _columns, _kbdColumn, _connected, _render, render_fn;
|
|
1243
|
+
var CommandsTable = class extends HTMLElement {
|
|
1244
|
+
constructor() {
|
|
1245
|
+
super(...arguments);
|
|
1246
|
+
__privateAdd(this, _render);
|
|
1247
|
+
__privateAdd(this, _commands, []);
|
|
1248
|
+
__privateAdd(this, _columns, commandsTableDefaultColumns);
|
|
1249
|
+
__privateAdd(this, _kbdColumn, "label");
|
|
1250
|
+
__privateAdd(this, _connected, false);
|
|
1251
|
+
}
|
|
1252
|
+
static get observedAttributes() {
|
|
1253
|
+
return ["title"];
|
|
1254
|
+
}
|
|
1255
|
+
set commands(value) {
|
|
1256
|
+
__privateSet(this, _commands, value);
|
|
1257
|
+
if (!__privateGet(this, _connected))
|
|
1258
|
+
return;
|
|
1259
|
+
__privateMethod(this, _render, render_fn).call(this);
|
|
1260
|
+
}
|
|
1261
|
+
get commands() {
|
|
1262
|
+
return __privateGet(this, _commands);
|
|
1263
|
+
}
|
|
1264
|
+
set columns(value) {
|
|
1265
|
+
__privateSet(this, _columns, value);
|
|
1266
|
+
if (!__privateGet(this, _connected))
|
|
1267
|
+
return;
|
|
1268
|
+
__privateMethod(this, _render, render_fn).call(this);
|
|
1269
|
+
}
|
|
1270
|
+
get columns() {
|
|
1271
|
+
return __privateGet(this, _columns);
|
|
1272
|
+
}
|
|
1273
|
+
/** Column id whose cells are wrapped in <kbd>. Defaults to 'label'. Set to null to disable. */
|
|
1274
|
+
set kbdColumn(value) {
|
|
1275
|
+
__privateSet(this, _kbdColumn, value);
|
|
1276
|
+
if (!__privateGet(this, _connected))
|
|
1277
|
+
return;
|
|
1278
|
+
__privateMethod(this, _render, render_fn).call(this);
|
|
1279
|
+
}
|
|
1280
|
+
get kbdColumn() {
|
|
1281
|
+
return __privateGet(this, _kbdColumn);
|
|
1282
|
+
}
|
|
1283
|
+
attributeChangedCallback() {
|
|
1284
|
+
if (!__privateGet(this, _connected))
|
|
1285
|
+
return;
|
|
1286
|
+
__privateMethod(this, _render, render_fn).call(this);
|
|
1287
|
+
}
|
|
1288
|
+
connectedCallback() {
|
|
1289
|
+
__privateSet(this, _connected, true);
|
|
1290
|
+
__privateMethod(this, _render, render_fn).call(this);
|
|
1291
|
+
}
|
|
1292
|
+
disconnectedCallback() {
|
|
1293
|
+
__privateSet(this, _connected, false);
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
_commands = new WeakMap();
|
|
1297
|
+
_columns = new WeakMap();
|
|
1298
|
+
_kbdColumn = new WeakMap();
|
|
1299
|
+
_connected = new WeakMap();
|
|
1300
|
+
_render = new WeakSet();
|
|
1301
|
+
render_fn = function() {
|
|
1302
|
+
this.replaceChildren();
|
|
1303
|
+
const headerCells = [];
|
|
1304
|
+
for (const column of __privateGet(this, _columns)) {
|
|
1305
|
+
const headerCell = document.createElement("th");
|
|
1306
|
+
headerCell.classList.add("dn-commands-table-th");
|
|
1307
|
+
headerCell.textContent = column.label;
|
|
1308
|
+
headerCells.push(headerCell);
|
|
1309
|
+
}
|
|
1310
|
+
const headerRow = document.createElement("tr");
|
|
1311
|
+
headerRow.classList.add("dn-commands-table-thead-tr");
|
|
1312
|
+
for (const headerCell of headerCells) {
|
|
1313
|
+
headerRow.appendChild(headerCell);
|
|
1314
|
+
}
|
|
1315
|
+
const thead = document.createElement("thead");
|
|
1316
|
+
thead.classList.add("dn-commands-table-thead");
|
|
1317
|
+
thead.appendChild(headerRow);
|
|
1318
|
+
const tbody = document.createElement("tbody");
|
|
1319
|
+
tbody.classList.add("dn-commands-table-tbody");
|
|
1320
|
+
for (const command of __privateGet(this, _commands)) {
|
|
1321
|
+
const rowCells = [];
|
|
1322
|
+
for (const column of __privateGet(this, _columns)) {
|
|
1323
|
+
const cellValue = command[column.id];
|
|
1324
|
+
const rowCell = document.createElement("td");
|
|
1325
|
+
rowCell.classList.add("dn-commands-table-td");
|
|
1326
|
+
if (__privateGet(this, _kbdColumn) !== null && column.id === __privateGet(this, _kbdColumn) && cellValue) {
|
|
1327
|
+
const kbd = document.createElement("kbd");
|
|
1328
|
+
kbd.classList.add("dn-commands-table-td-kbd");
|
|
1329
|
+
kbd.textContent = cellValue;
|
|
1330
|
+
rowCell.append(kbd);
|
|
1331
|
+
} else {
|
|
1332
|
+
rowCell.textContent = cellValue;
|
|
1333
|
+
}
|
|
1334
|
+
rowCells.push(rowCell);
|
|
1335
|
+
}
|
|
1336
|
+
const row = document.createElement("tr");
|
|
1337
|
+
row.classList.add("dn-commands-table-tbody-tr");
|
|
1338
|
+
for (const rowCell of rowCells) {
|
|
1339
|
+
row.appendChild(rowCell);
|
|
1340
|
+
}
|
|
1341
|
+
tbody.appendChild(row);
|
|
1342
|
+
}
|
|
1343
|
+
const table = document.createElement("table");
|
|
1344
|
+
table.classList.add("dn-commands-table");
|
|
1345
|
+
const title = this.getAttribute("title");
|
|
1346
|
+
if (title) {
|
|
1347
|
+
const caption = document.createElement("caption");
|
|
1348
|
+
caption.classList.add("dn-commands-table-caption");
|
|
1349
|
+
caption.textContent = title;
|
|
1350
|
+
table.appendChild(caption);
|
|
1351
|
+
} else {
|
|
1352
|
+
table.setAttribute("aria-label", "Commands table");
|
|
1353
|
+
}
|
|
1354
|
+
table.appendChild(thead);
|
|
1355
|
+
table.appendChild(tbody);
|
|
1356
|
+
this.appendChild(table);
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1193
1359
|
// src/rendering.ts
|
|
1194
1360
|
var rendering_default = (options) => {
|
|
1195
1361
|
const setActiveDescendant = (e) => {
|
|
@@ -1215,7 +1381,7 @@ var rendering_default = (options) => {
|
|
|
1215
1381
|
defaults.existingElement = options.defaults.existingElement ? __spreadValues(__spreadValues({}, defaults.existingElement), options.defaults.existingElement) : defaults.existingElement;
|
|
1216
1382
|
}
|
|
1217
1383
|
renderer.initialize = () => {
|
|
1218
|
-
var _a;
|
|
1384
|
+
var _a, _b;
|
|
1219
1385
|
if (initialized) {
|
|
1220
1386
|
console.error(
|
|
1221
1387
|
`The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ${options.suffixId}. No further action was taken.`
|
|
@@ -1246,6 +1412,9 @@ var rendering_default = (options) => {
|
|
|
1246
1412
|
if (options.root && options.root.height) {
|
|
1247
1413
|
renderer.wrapper.style.height = options.root.height;
|
|
1248
1414
|
}
|
|
1415
|
+
if ((_a = options.commandsElement) == null ? void 0 : _a.include) {
|
|
1416
|
+
renderer.initializeCommands(options.commandsElement);
|
|
1417
|
+
}
|
|
1249
1418
|
if (options.entryButton && options.entryButton.include) {
|
|
1250
1419
|
renderer.entryButton = document.createElement("button");
|
|
1251
1420
|
renderer.entryButton.id = "dn-entry-button-" + options.suffixId;
|
|
@@ -1260,7 +1429,7 @@ var rendering_default = (options) => {
|
|
|
1260
1429
|
renderer.wrapper.appendChild(renderer.entryButton);
|
|
1261
1430
|
}
|
|
1262
1431
|
renderer.root.appendChild(renderer.wrapper);
|
|
1263
|
-
if ((
|
|
1432
|
+
if ((_b = options.exitElement) == null ? void 0 : _b.include) {
|
|
1264
1433
|
renderer.exitElement = document.createElement("div");
|
|
1265
1434
|
renderer.exitElement.id = "dn-exit-" + options.suffixId;
|
|
1266
1435
|
renderer.exitElement.classList.add("dn-exit-position");
|
|
@@ -1270,17 +1439,17 @@ var rendering_default = (options) => {
|
|
|
1270
1439
|
renderer.exitElement.setAttribute("tabindex", "-1");
|
|
1271
1440
|
renderer.exitElement.style.display = "none";
|
|
1272
1441
|
renderer.exitElement.addEventListener("focus", (e) => {
|
|
1273
|
-
var _a2,
|
|
1442
|
+
var _a2, _b2;
|
|
1274
1443
|
renderer.exitElement.style.display = "block";
|
|
1275
1444
|
renderer.clearStructure();
|
|
1276
|
-
if ((
|
|
1445
|
+
if ((_b2 = (_a2 = options.exitElement) == null ? void 0 : _a2.callbacks) == null ? void 0 : _b2.focus) {
|
|
1277
1446
|
options.exitElement.callbacks.focus(e);
|
|
1278
1447
|
}
|
|
1279
1448
|
});
|
|
1280
1449
|
renderer.exitElement.addEventListener("blur", (e) => {
|
|
1281
|
-
var _a2,
|
|
1450
|
+
var _a2, _b2;
|
|
1282
1451
|
renderer.exitElement.style.display = "none";
|
|
1283
|
-
if ((
|
|
1452
|
+
if ((_b2 = (_a2 = options.exitElement) == null ? void 0 : _a2.callbacks) == null ? void 0 : _b2.blur) {
|
|
1284
1453
|
options.exitElement.callbacks.blur(e);
|
|
1285
1454
|
}
|
|
1286
1455
|
});
|
|
@@ -1393,6 +1562,31 @@ var rendering_default = (options) => {
|
|
|
1393
1562
|
}
|
|
1394
1563
|
});
|
|
1395
1564
|
};
|
|
1565
|
+
renderer.initializeCommands = (commandOptions) => {
|
|
1566
|
+
const root = document.getElementById(commandOptions == null ? void 0 : commandOptions.rootId);
|
|
1567
|
+
if (!root) {
|
|
1568
|
+
console.error("Commands root element not found in document.");
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
const optionsCommands = commandOptions.commands;
|
|
1572
|
+
const genericCommandsFromRules = getGenericCommandsFromNavRules(commandOptions.navigationRules);
|
|
1573
|
+
const commands = optionsCommands ? typeof optionsCommands === "function" ? optionsCommands(genericCommandsFromRules) : optionsCommands : genericCommandsFromRules;
|
|
1574
|
+
if (!customElements.get("dn-commands-table")) {
|
|
1575
|
+
customElements.define("dn-commands-table", CommandsTable);
|
|
1576
|
+
}
|
|
1577
|
+
const commandsElement = document.createElement("dn-commands-table");
|
|
1578
|
+
if (commandOptions == null ? void 0 : commandOptions.title) {
|
|
1579
|
+
commandsElement.setAttribute("title", commandOptions.title);
|
|
1580
|
+
}
|
|
1581
|
+
commandsElement.commands = commands;
|
|
1582
|
+
if (commandOptions.columns) {
|
|
1583
|
+
commandsElement.columns = commandOptions.columns;
|
|
1584
|
+
}
|
|
1585
|
+
root.appendChild(commandsElement);
|
|
1586
|
+
return commandsElement;
|
|
1587
|
+
};
|
|
1588
|
+
renderer.getGenericCommandsFromNavRules = getGenericCommandsFromNavRules;
|
|
1589
|
+
renderer.CommandsTable = CommandsTable;
|
|
1396
1590
|
return renderer;
|
|
1397
1591
|
};
|
|
1398
1592
|
|
|
@@ -1949,8 +2143,201 @@ var text_chat_default = (options) => {
|
|
|
1949
2143
|
};
|
|
1950
2144
|
};
|
|
1951
2145
|
|
|
2146
|
+
// src/geometry.ts
|
|
2147
|
+
function grahamScan(points) {
|
|
2148
|
+
if (points.length < 3)
|
|
2149
|
+
return [...points];
|
|
2150
|
+
let pivot = points[0];
|
|
2151
|
+
for (const p of points) {
|
|
2152
|
+
if (p.y < pivot.y || p.y === pivot.y && p.x < pivot.x)
|
|
2153
|
+
pivot = p;
|
|
2154
|
+
}
|
|
2155
|
+
const sorted = [...points].sort((a, b) => {
|
|
2156
|
+
const ax = a.x - pivot.x, ay = a.y - pivot.y;
|
|
2157
|
+
const bx = b.x - pivot.x, by = b.y - pivot.y;
|
|
2158
|
+
const cross2 = ax * by - ay * bx;
|
|
2159
|
+
if (cross2 !== 0)
|
|
2160
|
+
return -cross2;
|
|
2161
|
+
return ax * ax + ay * ay - (bx * bx + by * by);
|
|
2162
|
+
});
|
|
2163
|
+
const hull = [];
|
|
2164
|
+
for (const p of sorted) {
|
|
2165
|
+
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
|
|
2166
|
+
hull.pop();
|
|
2167
|
+
}
|
|
2168
|
+
hull.push(p);
|
|
2169
|
+
}
|
|
2170
|
+
return hull;
|
|
2171
|
+
}
|
|
2172
|
+
function cross(O, A, B) {
|
|
2173
|
+
return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
|
|
2174
|
+
}
|
|
2175
|
+
function convexHullPath(points) {
|
|
2176
|
+
if (points.length === 0)
|
|
2177
|
+
return "";
|
|
2178
|
+
if (points.length === 1) {
|
|
2179
|
+
const p = points[0];
|
|
2180
|
+
return `M${p.x},${p.y}Z`;
|
|
2181
|
+
}
|
|
2182
|
+
const hull = grahamScan(points);
|
|
2183
|
+
if (hull.length === 0)
|
|
2184
|
+
return "";
|
|
2185
|
+
const [first, ...rest] = hull;
|
|
2186
|
+
return `M${fmt(first.x)},${fmt(first.y)}` + rest.map((p) => `L${fmt(p.x)},${fmt(p.y)}`).join("") + "Z";
|
|
2187
|
+
}
|
|
2188
|
+
function expandHull(hullPoints, padPx) {
|
|
2189
|
+
if (padPx === 0 || hullPoints.length === 0)
|
|
2190
|
+
return hullPoints;
|
|
2191
|
+
const cx = hullPoints.reduce((s, p) => s + p.x, 0) / hullPoints.length;
|
|
2192
|
+
const cy = hullPoints.reduce((s, p) => s + p.y, 0) / hullPoints.length;
|
|
2193
|
+
return hullPoints.map((p) => {
|
|
2194
|
+
const dx = p.x - cx;
|
|
2195
|
+
const dy = p.y - cy;
|
|
2196
|
+
const dist = Math.hypot(dx, dy);
|
|
2197
|
+
if (dist === 0)
|
|
2198
|
+
return p;
|
|
2199
|
+
return { x: p.x + dx / dist * padPx, y: p.y + dy / dist * padPx };
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
function rectCorners(r) {
|
|
2203
|
+
return [
|
|
2204
|
+
{ x: r.x, y: r.y },
|
|
2205
|
+
{ x: r.x + r.width, y: r.y },
|
|
2206
|
+
{ x: r.x + r.width, y: r.y + r.height },
|
|
2207
|
+
{ x: r.x, y: r.y + r.height }
|
|
2208
|
+
];
|
|
2209
|
+
}
|
|
2210
|
+
function padRect(r, pad) {
|
|
2211
|
+
return { x: r.x - pad, y: r.y - pad, width: r.width + pad * 2, height: r.height + pad * 2 };
|
|
2212
|
+
}
|
|
2213
|
+
function convexHullOfRects(rects, padPx = 0) {
|
|
2214
|
+
if (rects.length === 0)
|
|
2215
|
+
return "";
|
|
2216
|
+
const corners = rects.flatMap(rectCorners);
|
|
2217
|
+
const hull = grahamScan(corners);
|
|
2218
|
+
const expanded = padPx > 0 ? expandHull(hull, padPx) : hull;
|
|
2219
|
+
return hullToPath(expanded);
|
|
2220
|
+
}
|
|
2221
|
+
function unionOfRectPaths(rects, padPx = 0) {
|
|
2222
|
+
if (rects.length === 0)
|
|
2223
|
+
return "";
|
|
2224
|
+
return rects.map((r) => {
|
|
2225
|
+
const pr = padPx > 0 ? padRect(r, padPx) : r;
|
|
2226
|
+
const { x, y, width: w, height: h } = pr;
|
|
2227
|
+
return `M${fmt(x)},${fmt(y)}L${fmt(x + w)},${fmt(y)}L${fmt(x + w)},${fmt(y + h)}L${fmt(x)},${fmt(y + h)}Z`;
|
|
2228
|
+
}).join("");
|
|
2229
|
+
}
|
|
2230
|
+
function boundingRectPath(rects, padPx = 0) {
|
|
2231
|
+
if (rects.length === 0)
|
|
2232
|
+
return "";
|
|
2233
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
2234
|
+
for (const r of rects) {
|
|
2235
|
+
minX = Math.min(minX, r.x);
|
|
2236
|
+
minY = Math.min(minY, r.y);
|
|
2237
|
+
maxX = Math.max(maxX, r.x + r.width);
|
|
2238
|
+
maxY = Math.max(maxY, r.y + r.height);
|
|
2239
|
+
}
|
|
2240
|
+
minX -= padPx;
|
|
2241
|
+
minY -= padPx;
|
|
2242
|
+
maxX += padPx;
|
|
2243
|
+
maxY += padPx;
|
|
2244
|
+
return `M${fmt(minX)},${fmt(minY)}L${fmt(maxX)},${fmt(minY)}L${fmt(maxX)},${fmt(maxY)}L${fmt(minX)},${fmt(maxY)}Z`;
|
|
2245
|
+
}
|
|
2246
|
+
function convexHullOfCircles(circles, padPx = 0) {
|
|
2247
|
+
if (circles.length === 0)
|
|
2248
|
+
return "";
|
|
2249
|
+
const SAMPLES = 16;
|
|
2250
|
+
const points = [];
|
|
2251
|
+
for (const { x, y, r } of circles) {
|
|
2252
|
+
const effectiveR = r + padPx;
|
|
2253
|
+
for (let i = 0; i < SAMPLES; i++) {
|
|
2254
|
+
const angle = 2 * Math.PI * i / SAMPLES;
|
|
2255
|
+
points.push({
|
|
2256
|
+
x: x + effectiveR * Math.cos(angle),
|
|
2257
|
+
y: y + effectiveR * Math.sin(angle)
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
return convexHullPath(points);
|
|
2262
|
+
}
|
|
2263
|
+
function offsetLinePath(points, offsetPx) {
|
|
2264
|
+
if (points.length < 2) {
|
|
2265
|
+
if (points.length === 1) {
|
|
2266
|
+
const p = points[0];
|
|
2267
|
+
return convexHullOfCircles([{ x: p.x, y: p.y, r: offsetPx }]);
|
|
2268
|
+
}
|
|
2269
|
+
return "";
|
|
2270
|
+
}
|
|
2271
|
+
const normals = [];
|
|
2272
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
2273
|
+
const dx = points[i + 1].x - points[i].x;
|
|
2274
|
+
const dy = points[i + 1].y - points[i].y;
|
|
2275
|
+
const len = Math.hypot(dx, dy);
|
|
2276
|
+
normals.push(len === 0 ? { x: 0, y: -1 } : { x: -dy / len, y: dx / len });
|
|
2277
|
+
}
|
|
2278
|
+
const vertexNormals = [];
|
|
2279
|
+
for (let i = 0; i < points.length; i++) {
|
|
2280
|
+
if (i === 0) {
|
|
2281
|
+
vertexNormals.push(normals[0]);
|
|
2282
|
+
} else if (i === points.length - 1) {
|
|
2283
|
+
vertexNormals.push(normals[normals.length - 1]);
|
|
2284
|
+
} else {
|
|
2285
|
+
const n1 = normals[i - 1];
|
|
2286
|
+
const n2 = normals[i];
|
|
2287
|
+
const avg = { x: (n1.x + n2.x) / 2, y: (n1.y + n2.y) / 2 };
|
|
2288
|
+
const len = Math.hypot(avg.x, avg.y);
|
|
2289
|
+
vertexNormals.push(len === 0 ? n1 : { x: avg.x / len, y: avg.y / len });
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
const left = points.map((p, i) => ({
|
|
2293
|
+
x: p.x + vertexNormals[i].x * offsetPx,
|
|
2294
|
+
y: p.y + vertexNormals[i].y * offsetPx
|
|
2295
|
+
}));
|
|
2296
|
+
const right = points.map((p, i) => ({
|
|
2297
|
+
x: p.x - vertexNormals[i].x * offsetPx,
|
|
2298
|
+
y: p.y - vertexNormals[i].y * offsetPx
|
|
2299
|
+
})).reverse();
|
|
2300
|
+
const firstLeft = left[0];
|
|
2301
|
+
let d = `M${fmt(firstLeft.x)},${fmt(firstLeft.y)}`;
|
|
2302
|
+
for (let i = 1; i < left.length; i++) {
|
|
2303
|
+
d += `L${fmt(left[i].x)},${fmt(left[i].y)}`;
|
|
2304
|
+
}
|
|
2305
|
+
const lastLeft = left[left.length - 1];
|
|
2306
|
+
const firstRight = right[0];
|
|
2307
|
+
d += arcCap(lastLeft, firstRight, offsetPx);
|
|
2308
|
+
for (let i = 1; i < right.length; i++) {
|
|
2309
|
+
d += `L${fmt(right[i].x)},${fmt(right[i].y)}`;
|
|
2310
|
+
}
|
|
2311
|
+
const lastRight = right[right.length - 1];
|
|
2312
|
+
d += arcCap(lastRight, firstLeft, offsetPx);
|
|
2313
|
+
d += "Z";
|
|
2314
|
+
return d;
|
|
2315
|
+
}
|
|
2316
|
+
function arcCap(from, to, r) {
|
|
2317
|
+
return `A${fmt(r)},${fmt(r)},0,0,0,${fmt(to.x)},${fmt(to.y)}`;
|
|
2318
|
+
}
|
|
2319
|
+
function fmt(n) {
|
|
2320
|
+
return Math.round(n * 100) / 100 + "";
|
|
2321
|
+
}
|
|
2322
|
+
function hullToPath(hull) {
|
|
2323
|
+
if (hull.length === 0)
|
|
2324
|
+
return "";
|
|
2325
|
+
const [first, ...rest] = hull;
|
|
2326
|
+
return `M${fmt(first.x)},${fmt(first.y)}` + rest.map((p) => `L${fmt(p.x)},${fmt(p.y)}`).join("") + "Z";
|
|
2327
|
+
}
|
|
2328
|
+
|
|
1952
2329
|
// src/index.ts
|
|
1953
2330
|
var src_default = { structure: structure_default, input: input_default, rendering: rendering_default, textChat: text_chat_default };
|
|
1954
2331
|
export {
|
|
1955
|
-
|
|
2332
|
+
boundingRectPath,
|
|
2333
|
+
convexHullOfCircles,
|
|
2334
|
+
convexHullOfRects,
|
|
2335
|
+
convexHullPath,
|
|
2336
|
+
createValidId,
|
|
2337
|
+
src_default as default,
|
|
2338
|
+
describeNode,
|
|
2339
|
+
expandHull,
|
|
2340
|
+
grahamScan,
|
|
2341
|
+
offsetLinePath,
|
|
2342
|
+
unionOfRectPaths
|
|
1956
2343
|
};
|
package/dist/input.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var v=(r,t)=>{for(var o in t)p(r,o,{get:t[o],enumerable:!0})},x=(r,t,o,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of m(t))!b.call(r,e)&&e!==o&&p(r,e,{get:()=>t[e],enumerable:!(l=k(t,e))||l.enumerable});return r};var h=r=>x(p({},"__esModule",{value:!0}),r);var R={};v(R,{default:()=>N});module.exports=h(R);var g={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down",Period:"forward",Comma:"backward",Escape:"drill-out",Enter:"drill-in"};var f={left:{key:"ArrowLeft",direction:"source"},right:{key:"ArrowRight",direction:"target"},up:{key:"ArrowUp",direction:"source"},down:{key:"ArrowDown",direction:"target"},"drill-in":{key:"Enter",direction:"target"},"drill-out":{key:"Backspace",direction:"source"},backward:{key:"Comma",direction:"source"},forward:{key:"Period",direction:"target"},previous:{key:"Semicolon",direction:"source"},next:{key:"Quote",direction:"target"},exit:{key:"Escape",direction:"target"},help:{key:"KeyY",direction:"target"},undo:{key:"KeyZ",direction:"target"}};var N=r=>{let t={},o=g,l=f;return t.moveTo=e=>{let i=r.structure.nodes[e];if(i)return i},t.move=(e,i)=>{if(e){let a=r.structure.nodes[e];if(a.edges){let d=null,s=0,u=l[i];if(!u)return;let w=(c,n)=>{if(c!==i)return null;let y={target:typeof n.target=="string"?n.target:n.target(a,e),source:typeof n.source=="string"?n.source:n.source(a,e)};return y[u.direction]!==e?y[u.direction]:null};for(s=0;s<a.edges.length;s++){let c=r.structure.edges[a.edges[s]];if(c.navigationRules.forEach(n=>{d||(d=w(n,c))}),d)break}return d?t.moveTo(d):void 0}}},t.enter=()=>{if(r.entryPoint)return t.moveTo(r.entryPoint);console.error("No entry point was specified in InputOptions, returning undefined")},t.exit=()=>{if(r.exitPoint)return r.exitPoint;console.error("No exit point was specified in InputOptions, returning undefined")},t.keydownValidator=e=>{let i=o[e.code];if(i)return i},t.focus=e=>{let i=document.getElementById(e);i&&i.focus()},t.setNavigationKeyBindings=e=>{e?(o={},l=e,Object.keys(e).forEach(i=>{let a=e[i];o[a.key]=i})):(o=g,l=f)},t.setNavigationKeyBindings(r.navigationRules),t};
|
package/dist/input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-UNB4R2QN.js";import"./chunk-7YO7HC2V.js";export{a as default};
|
package/dist/rendering.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var b=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var O=(e,r,i)=>r in e?b(e,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[r]=i,o=(e,r)=>{for(var i in r||(r={}))T.call(r,i)&&O(e,i,r[i]);if(N)for(var i of N(r))j.call(r,i)&&O(e,i,r[i]);return e};var F=(e,r)=>{for(var i in r)b(e,i,{get:r[i],enumerable:!0})},U=(e,r,i,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of I(r))!T.call(e,m)&&m!==i&&b(e,m,{get:()=>r[m],enumerable:!(t=K(r,m))||t.enumerable});return e};var z=e=>U(b({},"__esModule",{value:!0}),e);var $={};F($,{default:()=>G});module.exports=z($);var w={cssClass:void 0,spatialProperties:{x:0,y:0,width:0,height:0,path:""},semantics:{label:"",elementType:"div",role:"image",attributes:void 0},parentSemantics:{label:"",elementType:"figure",role:"figure",attributes:void 0},existingElement:{useForSpatialProperties:!1,spatialProperties:void 0}};var G=e=>{let r=l=>{t.wrapper.setAttribute("aria-activedescendant",l.srcElement.id)},i=()=>{t.wrapper.setAttribute("aria-activedescendant","")},t={},m=!1,n={cssClass:w.cssClass,spatialProperties:o({},w.spatialProperties),semantics:o({},w.semantics),parentSemantics:o({},w.parentSemantics),existingElement:o({},w.existingElement)};return e.defaults&&(n.cssClass=e.defaults.cssClass||n.cssClass,n.spatialProperties=e.defaults.spatialProperties?o(o({},n.spatialProperties),e.defaults.spatialProperties):n.spatialProperties,n.semantics=e.defaults.semantics?o(o({},n.semantics),e.defaults.semantics):n.semantics,n.parentSemantics=e.defaults.parentSemantics?o(o({},n.parentSemantics),e.defaults.parentSemantics):n.parentSemantics,n.existingElement=e.defaults.existingElement?o(o({},n.existingElement),e.defaults.existingElement):n.existingElement),t.initialize=()=>{var l;if(m){console.error(`The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ${e.suffixId}. No further action was taken.`);return}if(e.root&&document.getElementById(e.root.id))t.root=document.getElementById(e.root.id);else{console.error("No root element found, cannot build: RenderingOptions.root.id must reference an existing DOM element in order to render children.");return}if(t.root.style.position="relative",t.root.classList.add("dn-root"),!e.suffixId){console.error("No suffix id found: options.suffixId must be specified.");return}return t.wrapper=document.createElement("div"),t.wrapper.id="dn-wrapper-"+e.suffixId,t.wrapper.setAttribute("role","application"),t.wrapper.setAttribute("aria-label",e.root.description||"Data navigation structure"),t.wrapper.setAttribute("aria-activedescendant",""),t.wrapper.classList.add("dn-wrapper"),t.wrapper.style.width=e.root&&e.root.width?e.root.width:"100%",e.root&&e.root.height&&(t.wrapper.style.height=e.root.height),e.entryButton&&e.entryButton.include&&(t.entryButton=document.createElement("button"),t.entryButton.id="dn-entry-button-"+e.suffixId,t.entryButton.classList.add("dn-entry-button"),t.entryButton.innerText="Enter navigation area",e.entryButton.callbacks&&e.entryButton.callbacks.click&&t.entryButton.addEventListener("click",e.entryButton.callbacks.click),e.entryButton.callbacks&&e.entryButton.callbacks.focus&&t.entryButton.addEventListener("focus",e.entryButton.callbacks.focus),t.wrapper.appendChild(t.entryButton)),t.root.appendChild(t.wrapper),(l=e.exitElement)!=null&&l.include&&(t.exitElement=document.createElement("div"),t.exitElement.id="dn-exit-"+e.suffixId,t.exitElement.classList.add("dn-exit-position"),t.exitElement.innerText="End of data structure.",t.exitElement.setAttribute("aria-label","End of data structure."),t.exitElement.setAttribute("role","note"),t.exitElement.setAttribute("tabindex","-1"),t.exitElement.style.display="none",t.exitElement.addEventListener("focus",d=>{var c,y;t.exitElement.style.display="block",t.clearStructure(),(y=(c=e.exitElement)==null?void 0:c.callbacks)!=null&&y.focus&&e.exitElement.callbacks.focus(d)}),t.exitElement.addEventListener("blur",d=>{var c,y;t.exitElement.style.display="none",(y=(c=e.exitElement)==null?void 0:c.callbacks)!=null&&y.blur&&e.exitElement.callbacks.blur(d)}),t.root.appendChild(t.exitElement)),m=!0,t.root},t.render=l=>{let d=l.renderId+"",c=e.elementData[d];if(!c){console.warn(`Render data not found with renderId: ${d}. Failed to render.`);return}if(!m){console.error("render() was called before initialize(), renderer must be initialized first.");return}let y=!1,B={},s=(u,g,p)=>{var C;let f=c[u]||n[u],A=p&&y?B[g]:f==null?void 0:f[g],D=(C=n[u])==null?void 0:C[g];return typeof f=="function"?f(c,l.datum):typeof A=="function"?A(c,l.datum):A||D||(g?void 0:f)};y=s("existingElement","useForSpatialProperties"),B=s("existingElement","spatialProperties");let L=parseFloat(s("spatialProperties","width",!0)||0),P=parseFloat(s("spatialProperties","height",!0)||0),h=parseFloat(s("spatialProperties","x",!0)||0),E=parseFloat(s("spatialProperties","y",!0)||0),a=document.createElement(s("parentSemantics","elementType")),k=s("parentSemantics","attributes");typeof k=="object"&&Object.keys(k).forEach(u=>{a.setAttribute(u,k[u])}),a.setAttribute("role",s("parentSemantics","role")),a.id=d,a.classList.add("dn-node"),a.classList.add(s("cssClass")),a.style.width=L+"px",a.style.height=P+"px",a.style.left=h+"px",a.style.top=E+"px",a.setAttribute("tabindex","0"),a.addEventListener("focus",r),a.addEventListener("blur",i);let x=document.createElement(s("semantics","elementType")),v=s("semantics","attributes");typeof v=="object"&&Object.keys(v).forEach(u=>{a.setAttribute(u,v[u])}),x.setAttribute("role",s("semantics","role")),x.classList.add("dn-node-text"),c.showText&&(x.innerText=c.semantics.label);let S=s("semantics","label");S||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),x.setAttribute("aria-label",S),a.appendChild(x);let R=s("spatialProperties","path");if(R){let u=L+h+10,g=P+E+10,p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("width",u+""),p.setAttribute("height",g+""),p.setAttribute("viewBox",`0 0 ${u} ${g}`),p.style.left=-h+"px",p.style.top=-E+"px",p.classList.add("dn-node-svg"),p.setAttribute("role","presentation"),p.setAttribute("focusable","false");let f=document.createElementNS("http://www.w3.org/2000/svg","path");f.setAttribute("d",R),f.classList.add("dn-node-path"),p.appendChild(f),a.appendChild(p)}return t.wrapper.appendChild(a),a},t.remove=l=>{let d=document.getElementById(l);t.wrapper.getAttribute("aria-activedescendant")===l&&t.wrapper.setAttribute("aria-activedescendant",""),d&&(d.removeEventListener("focus",r),d.removeEventListener("blur",i),d.remove())},t.clearStructure=()=>{[...t.wrapper.children].forEach(l=>{t.entryButton&&t.entryButton===l||t.remove(l.id)})},t};
|
|
1
|
+
var T=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames,H=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var W=(e,r,n)=>r in e?T(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,p=(e,r)=>{for(var n in r||(r={}))Z.call(r,n)&&W(e,n,r[n]);if(H)for(var n of H(r))q.call(r,n)&&W(e,n,r[n]);return e};var X=(e,r)=>{for(var n in r)T(e,n,{get:r[n],enumerable:!0})},ee=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of Q(r))!Z.call(e,m)&&m!==n&&T(e,m,{get:()=>r[m],enumerable:!(t=Y(r,m))||t.enumerable});return e};var te=e=>ee(T({},"__esModule",{value:!0}),e);var G=(e,r,n)=>{if(!r.has(e))throw TypeError("Cannot "+n)};var f=(e,r,n)=>(G(e,r,"read from private field"),n?n.call(e):r.get(e)),L=(e,r,n)=>{if(r.has(e))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(e):r.set(e,n)},B=(e,r,n,t)=>(G(e,r,"write to private field"),t?t.call(e,n):r.set(e,n),n);var N=(e,r,n)=>(G(e,r,"access private method"),n);var ne={};X(ne,{default:()=>re});module.exports=te(ne);var R={cssClass:void 0,spatialProperties:{x:0,y:0,width:0,height:0,path:""},semantics:{label:"",elementType:"div",role:"image",attributes:void 0},parentSemantics:{label:"",elementType:"figure",role:"figure",attributes:void 0},existingElement:{useForSpatialProperties:!1,spatialProperties:void 0}},_={"drill-in":{label:"Enter",description:"Drill in"},"drill-out":{label:"Backspace",description:"Drill out"},exit:{label:"Esc",description:"Exit"},left:{label:"\u2190",description:"Previous data point"},right:{label:"\u2192",description:"Next data point"},up:{label:"\u2191",description:"Previous data point"},down:{label:"\u2193",description:"Next data point"},backward:{label:",",description:"Move backward"},forward:{label:".",description:"Move forward"},previous:{label:";",description:"Previous"},next:{label:"'",description:"Next"},undo:{label:"Z",description:"Undo"},help:{label:"Y",description:"Help"},legend:{label:"L",description:"Legend"}},J=[{label:"Command",id:"description"},{label:"Key",id:"label"}];var D,v,k,y,x,P,S=class extends HTMLElement{constructor(){super(...arguments);L(this,x);L(this,D,[]);L(this,v,J);L(this,k,"label");L(this,y,!1)}static get observedAttributes(){return["title"]}set commands(n){B(this,D,n),f(this,y)&&N(this,x,P).call(this)}get commands(){return f(this,D)}set columns(n){B(this,v,n),f(this,y)&&N(this,x,P).call(this)}get columns(){return f(this,v)}set kbdColumn(n){B(this,k,n),f(this,y)&&N(this,x,P).call(this)}get kbdColumn(){return f(this,k)}attributeChangedCallback(){f(this,y)&&N(this,x,P).call(this)}connectedCallback(){B(this,y,!0),N(this,x,P).call(this)}disconnectedCallback(){B(this,y,!1)}};D=new WeakMap,v=new WeakMap,k=new WeakMap,y=new WeakMap,x=new WeakSet,P=function(){this.replaceChildren();let n=[];for(let s of f(this,v)){let o=document.createElement("th");o.classList.add("dn-commands-table-th"),o.textContent=s.label,n.push(o)}let t=document.createElement("tr");t.classList.add("dn-commands-table-thead-tr");for(let s of n)t.appendChild(s);let m=document.createElement("thead");m.classList.add("dn-commands-table-thead"),m.appendChild(t);let l=document.createElement("tbody");l.classList.add("dn-commands-table-tbody");for(let s of f(this,D)){let o=[];for(let i of f(this,v)){let A=s[i.id],w=document.createElement("td");if(w.classList.add("dn-commands-table-td"),f(this,k)!==null&&i.id===f(this,k)&&A){let E=document.createElement("kbd");E.classList.add("dn-commands-table-td-kbd"),E.textContent=A,w.append(E)}else w.textContent=A;o.push(w)}let u=document.createElement("tr");u.classList.add("dn-commands-table-tbody-tr");for(let i of o)u.appendChild(i);l.appendChild(u)}let a=document.createElement("table");a.classList.add("dn-commands-table");let d=this.getAttribute("title");if(d){let s=document.createElement("caption");s.classList.add("dn-commands-table-caption"),s.textContent=d,a.appendChild(s)}else a.setAttribute("aria-label","Commands table");a.appendChild(m),a.appendChild(l),this.appendChild(a)};function z(e){return e?Object.keys(e).map(r=>_[r]).filter(Boolean):[]}var re=e=>{let r=a=>{t.wrapper.setAttribute("aria-activedescendant",a.srcElement.id)},n=()=>{t.wrapper.setAttribute("aria-activedescendant","")},t={},m=!1,l={cssClass:R.cssClass,spatialProperties:p({},R.spatialProperties),semantics:p({},R.semantics),parentSemantics:p({},R.parentSemantics),existingElement:p({},R.existingElement)};return e.defaults&&(l.cssClass=e.defaults.cssClass||l.cssClass,l.spatialProperties=e.defaults.spatialProperties?p(p({},l.spatialProperties),e.defaults.spatialProperties):l.spatialProperties,l.semantics=e.defaults.semantics?p(p({},l.semantics),e.defaults.semantics):l.semantics,l.parentSemantics=e.defaults.parentSemantics?p(p({},l.parentSemantics),e.defaults.parentSemantics):l.parentSemantics,l.existingElement=e.defaults.existingElement?p(p({},l.existingElement),e.defaults.existingElement):l.existingElement),t.initialize=()=>{var a,d;if(m){console.error(`The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ${e.suffixId}. No further action was taken.`);return}if(e.root&&document.getElementById(e.root.id))t.root=document.getElementById(e.root.id);else{console.error("No root element found, cannot build: RenderingOptions.root.id must reference an existing DOM element in order to render children.");return}if(t.root.style.position="relative",t.root.classList.add("dn-root"),!e.suffixId){console.error("No suffix id found: options.suffixId must be specified.");return}return t.wrapper=document.createElement("div"),t.wrapper.id="dn-wrapper-"+e.suffixId,t.wrapper.setAttribute("role","application"),t.wrapper.setAttribute("aria-label",e.root.description||"Data navigation structure"),t.wrapper.setAttribute("aria-activedescendant",""),t.wrapper.classList.add("dn-wrapper"),t.wrapper.style.width=e.root&&e.root.width?e.root.width:"100%",e.root&&e.root.height&&(t.wrapper.style.height=e.root.height),(a=e.commandsElement)!=null&&a.include&&t.initializeCommands(e.commandsElement),e.entryButton&&e.entryButton.include&&(t.entryButton=document.createElement("button"),t.entryButton.id="dn-entry-button-"+e.suffixId,t.entryButton.classList.add("dn-entry-button"),t.entryButton.innerText="Enter navigation area",e.entryButton.callbacks&&e.entryButton.callbacks.click&&t.entryButton.addEventListener("click",e.entryButton.callbacks.click),e.entryButton.callbacks&&e.entryButton.callbacks.focus&&t.entryButton.addEventListener("focus",e.entryButton.callbacks.focus),t.wrapper.appendChild(t.entryButton)),t.root.appendChild(t.wrapper),(d=e.exitElement)!=null&&d.include&&(t.exitElement=document.createElement("div"),t.exitElement.id="dn-exit-"+e.suffixId,t.exitElement.classList.add("dn-exit-position"),t.exitElement.innerText="End of data structure.",t.exitElement.setAttribute("aria-label","End of data structure."),t.exitElement.setAttribute("role","note"),t.exitElement.setAttribute("tabindex","-1"),t.exitElement.style.display="none",t.exitElement.addEventListener("focus",s=>{var o,u;t.exitElement.style.display="block",t.clearStructure(),(u=(o=e.exitElement)==null?void 0:o.callbacks)!=null&&u.focus&&e.exitElement.callbacks.focus(s)}),t.exitElement.addEventListener("blur",s=>{var o,u;t.exitElement.style.display="none",(u=(o=e.exitElement)==null?void 0:o.callbacks)!=null&&u.blur&&e.exitElement.callbacks.blur(s)}),t.root.appendChild(t.exitElement)),m=!0,t.root},t.render=a=>{let d=a.renderId+"",s=e.elementData[d];if(!s){console.warn(`Render data not found with renderId: ${d}. Failed to render.`);return}if(!m){console.error("render() was called before initialize(), renderer must be initialized first.");return}let o=!1,u={},i=(b,C,h)=>{var $;let g=s[b]||l[b],O=h&&o?u[C]:g==null?void 0:g[C],V=($=l[b])==null?void 0:$[C];return typeof g=="function"?g(s,a.datum):typeof O=="function"?O(s,a.datum):O||V||(C?void 0:g)};o=i("existingElement","useForSpatialProperties"),u=i("existingElement","spatialProperties");let A=parseFloat(i("spatialProperties","width",!0)||0),w=parseFloat(i("spatialProperties","height",!0)||0),E=parseFloat(i("spatialProperties","x",!0)||0),I=parseFloat(i("spatialProperties","y",!0)||0),c=document.createElement(i("parentSemantics","elementType")),F=i("parentSemantics","attributes");typeof F=="object"&&Object.keys(F).forEach(b=>{c.setAttribute(b,F[b])}),c.setAttribute("role",i("parentSemantics","role")),c.id=d,c.classList.add("dn-node"),c.classList.add(i("cssClass")),c.style.width=A+"px",c.style.height=w+"px",c.style.left=E+"px",c.style.top=I+"px",c.setAttribute("tabindex","0"),c.addEventListener("focus",r),c.addEventListener("blur",n);let j=document.createElement(i("semantics","elementType")),K=i("semantics","attributes");typeof K=="object"&&Object.keys(K).forEach(b=>{c.setAttribute(b,K[b])}),j.setAttribute("role",i("semantics","role")),j.classList.add("dn-node-text"),s.showText&&(j.innerText=s.semantics.label);let U=i("semantics","label");U||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),j.setAttribute("aria-label",U),c.appendChild(j);let M=i("spatialProperties","path");if(M){let b=A+E+10,C=w+I+10,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("width",b+""),h.setAttribute("height",C+""),h.setAttribute("viewBox",`0 0 ${b} ${C}`),h.style.left=-E+"px",h.style.top=-I+"px",h.classList.add("dn-node-svg"),h.setAttribute("role","presentation"),h.setAttribute("focusable","false");let g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",M),g.classList.add("dn-node-path"),h.appendChild(g),c.appendChild(h)}return t.wrapper.appendChild(c),c},t.remove=a=>{let d=document.getElementById(a);t.wrapper.getAttribute("aria-activedescendant")===a&&t.wrapper.setAttribute("aria-activedescendant",""),d&&(d.removeEventListener("focus",r),d.removeEventListener("blur",n),d.remove())},t.clearStructure=()=>{[...t.wrapper.children].forEach(a=>{t.entryButton&&t.entryButton===a||t.remove(a.id)})},t.initializeCommands=a=>{let d=document.getElementById(a==null?void 0:a.rootId);if(!d){console.error("Commands root element not found in document.");return}let s=a.commands,o=z(a.navigationRules),u=s?typeof s=="function"?s(o):s:o;customElements.get("dn-commands-table")||customElements.define("dn-commands-table",S);let i=document.createElement("dn-commands-table");return a!=null&&a.title&&i.setAttribute("title",a.title),i.commands=u,a.columns&&(i.columns=a.columns),d.appendChild(i),i},t.getGenericCommandsFromNavRules=z,t.CommandsTable=S,t};
|