@hpcc-js/graph 3.5.3 → 3.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/graph",
3
- "version": "3.5.3",
3
+ "version": "3.6.1",
4
4
  "description": "hpcc-js - Viz Graph",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.cjs",
@@ -38,18 +38,18 @@
38
38
  "update-major": "npx --yes npm-check-updates -u"
39
39
  },
40
40
  "dependencies": {
41
- "@hpcc-js/api": "^3.4.3",
42
- "@hpcc-js/common": "^3.5.3",
43
- "@hpcc-js/html": "^3.3.3",
44
- "@hpcc-js/react": "^3.4.3",
45
- "@hpcc-js/util": "^3.4.3"
41
+ "@hpcc-js/api": "^3.4.5",
42
+ "@hpcc-js/common": "^3.6.1",
43
+ "@hpcc-js/html": "^3.3.5",
44
+ "@hpcc-js/react": "^3.4.5",
45
+ "@hpcc-js/util": "^3.4.4"
46
46
  },
47
47
  "optionalPeerDependencies": {
48
48
  "react": ">=17.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@hpcc-js/esbuild-plugins": "^1.7.0",
52
- "@hpcc-js/wasm-graphviz": "1.15.0",
51
+ "@hpcc-js/esbuild-plugins": "^1.8.0",
52
+ "@hpcc-js/wasm-graphviz": "1.17.0",
53
53
  "@types/d3-transition": "1.3.6",
54
54
  "@types/dagre": "0.7.53",
55
55
  "d3-force": "^1",
@@ -73,5 +73,5 @@
73
73
  "url": "https://github.com/hpcc-systems/Visualization/issues"
74
74
  },
75
75
  "homepage": "https://github.com/hpcc-systems/Visualization",
76
- "gitHead": "0289b8552e19395a8da9b70a154821cf70ce42e7"
76
+ "gitHead": "70194f16ed27ea1167af126b35cbf4af5f181be9"
77
77
  }
@@ -30,4 +30,10 @@
30
30
 
31
31
  .graph_GraphT g.selected circle {
32
32
  stroke: navy !important;
33
+ }
34
+
35
+ .graph_GraphT .graphVertex:focus,
36
+ .graph_GraphT .graphVertex:focus-visible {
37
+ outline: 2px solid #0078d4;
38
+ outline-offset: 2px;
33
39
  }
@@ -747,6 +747,34 @@ export class GraphT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E e
747
747
  .on("contextmenu", function (this: SVGElement, d) {
748
748
  d3Event().preventDefault();
749
749
  })
750
+ .on("keydown", function (this: SVGElement, d) {
751
+ if (!context.tabNavigation()) return;
752
+ const event = d3Event() as KeyboardEvent;
753
+ const isSpace = event.code === "Space" || event.key === " " || event.key === "Spacebar";
754
+ const isEnter = event.key === "Enter";
755
+ if (!(isSpace || isEnter)) return;
756
+
757
+ event.preventDefault();
758
+ const selectionItem = {
759
+ _id: String(d.id),
760
+ element: () => d.element as any
761
+ };
762
+ if (event.ctrlKey || event.metaKey) {
763
+ if (context._selection.isSelected(selectionItem)) {
764
+ context._selection.remove(selectionItem);
765
+ } else {
766
+ context._selection.append(selectionItem);
767
+ }
768
+ } else {
769
+ context._selection.clear();
770
+ context._selection.append(selectionItem);
771
+ }
772
+
773
+ context.selectionChanged();
774
+ const selected = d.element.classed("selected");
775
+ const eventOrigin = context.resolveEventOrigin();
776
+ context.vertex_click(d.props.origData || d.props, "", selected, eventOrigin);
777
+ })
750
778
  .on("mousein", function (d) {
751
779
  Utility.safeRaise(this);
752
780
  context.highlightVertex(d3Select(this), d);
@@ -798,6 +826,10 @@ export class GraphT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E e
798
826
  .classed("centroid", d => d.props.centroid)
799
827
  .attr("opacity", d => d.props.hidden ? 0 : 1)
800
828
  .attr("filter", d => d.props.centroid ? "url(#" + this.id() + "_glow)" : null)
829
+ .attr("tabindex", d => context.tabNavigation() && !d.props.hidden ? 0 : null)
830
+ .attr("role", context.tabNavigation() ? "button" : null)
831
+ .attr("aria-label", d => context.tabNavigation() ? context.vertexAriaLabel(d) : null)
832
+ .attr("aria-hidden", d => d.props.hidden ? "true" : null)
801
833
  .each(function (this: any, d) {
802
834
  const props = context.calcProps(
803
835
  {
@@ -815,6 +847,10 @@ export class GraphT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E e
815
847
  return { ...props };
816
848
  }
817
849
 
850
+ protected vertexAriaLabel(d: VertexPlaceholder<V>): string {
851
+ return d.props?.text || `Vertex ${d.id}`;
852
+ }
853
+
818
854
  hasSubgraphs() {
819
855
  switch (this.layout()) {
820
856
  case "DOT":
@@ -1008,6 +1044,21 @@ export class GraphT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E e
1008
1044
  update(domNode, element) {
1009
1045
  super.update(domNode, element);
1010
1046
 
1047
+ const hostDiv = this.parentRelativeDiv;
1048
+ if (this.tabNavigation() && hostDiv) {
1049
+ const vertexCount = this._graphData?.allVertices().length ?? 0;
1050
+ const ariaLabel = vertexCount ? `Graph data (${vertexCount} vertices)` : "Graph data";
1051
+ hostDiv
1052
+ .attr("tabindex", "0")
1053
+ .attr("role", "group")
1054
+ .attr("aria-label", ariaLabel);
1055
+ } else if (hostDiv) {
1056
+ hostDiv
1057
+ .attr("tabindex", null)
1058
+ .attr("role", null)
1059
+ .attr("aria-label", null);
1060
+ }
1061
+
1011
1062
  this._renderElement.classed("allowDragging", this.allowDragging());
1012
1063
  if (this._centroidFilter) {
1013
1064
  this._centroidFilter.update(this.selectionGlowColor());
@@ -1178,6 +1229,8 @@ export interface GraphT<SG extends SubgraphBaseProps = any, V extends VertexBase
1178
1229
  showVertexLabels(_: boolean): this;
1179
1230
  showVertexLabelsOnHighlight(): boolean;
1180
1231
  showVertexLabelsOnHighlight(_: boolean): this;
1232
+ tabNavigation(): boolean;
1233
+ tabNavigation(_: boolean): this;
1181
1234
 
1182
1235
  hierarchyRankDirection(): "TB" | "BT" | "LR" | "RL";
1183
1236
  hierarchyRankDirection(_: "TB" | "BT" | "LR" | "RL"): this;
@@ -1250,6 +1303,7 @@ GraphT.prototype.publish("showEdgeLabels", true, "boolean", "Show Edge labels");
1250
1303
  GraphT.prototype.publish("showEdgeLabelsOnHighlight", true, "boolean", "Show Edge labels when highlighted");
1251
1304
  GraphT.prototype.publish("showVertexLabels", true, "boolean", "Show Vertex labels");
1252
1305
  GraphT.prototype.publish("showVertexLabelsOnHighlight", true, "boolean", "Show Vertex labels when highlighted");
1306
+ GraphT.prototype.publish("tabNavigation", false, "boolean", "Enable or disable tab navigation");
1253
1307
  GraphT.prototype.publish("snapToGrid", 0, "number", "Snap to Grid");
1254
1308
  GraphT.prototype.publish("selectionClearOnBackgroundClick", false, "boolean", "Clear selection on background click");
1255
1309
  GraphT.prototype.publish("edgeArcDepth", 8, "number", "Edge Arc Depth");
@@ -1,7 +1,6 @@
1
1
  import { GraphHtmlT, SubgraphBaseProps, EdgeBaseProps } from "./graphHtmlT.ts";
2
2
  import { vertex, VertexProps } from "./vertex.ts";
3
3
  import { edge, EdgeProps } from "./edge.ts";
4
- import { Vertex } from "@hpcc-js/util";
5
4
 
6
5
  export class GraphHtml extends GraphHtmlT<SubgraphBaseProps, VertexProps, EdgeProps<VertexProps>> {
7
6
  constructor() {
@@ -107,6 +107,7 @@ export declare class GraphT<SG extends SubgraphBaseProps, V extends VertexBasePr
107
107
  vertexMapper(props: V, origRow: V): V;
108
108
  updateVertices(): this;
109
109
  calcProps(props: V): V;
110
+ protected vertexAriaLabel(d: VertexPlaceholder<V>): string;
110
111
  hasSubgraphs(): boolean;
111
112
  private _subgraphRenderer;
112
113
  subgraphRenderer(): RendererT<SG>;
@@ -171,6 +172,8 @@ export interface GraphT<SG extends SubgraphBaseProps = any, V extends VertexBase
171
172
  showVertexLabels(_: boolean): this;
172
173
  showVertexLabelsOnHighlight(): boolean;
173
174
  showVertexLabelsOnHighlight(_: boolean): this;
175
+ tabNavigation(): boolean;
176
+ tabNavigation(_: boolean): this;
174
177
  hierarchyRankDirection(): "TB" | "BT" | "LR" | "RL";
175
178
  hierarchyRankDirection(_: "TB" | "BT" | "LR" | "RL"): this;
176
179
  hierarchyNodeSeparation(): number;