data-navigator 1.0.1 → 1.1.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/LICENSE CHANGED
@@ -1,29 +1,21 @@
1
- BSD 3-Clause License
1
+ MIT License
2
2
 
3
- Copyright (c) 2022, CMU Data Interaction Group
4
- All rights reserved.
3
+ Copyright (c) 2023 Carnegie Mellon University
5
4
 
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions are met:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
8
11
 
9
- 1. Redistributions of source code must retain the above copyright notice, this
10
- list of conditions and the following disclaimer.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
11
14
 
12
- 2. Redistributions in binary form must reproduce the above copyright notice,
13
- this list of conditions and the following disclaimer in the documentation
14
- and/or other materials provided with the distribution.
15
-
16
- 3. Neither the name of the copyright holder nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,9 +1,13 @@
1
- # Data-Navigator
1
+ # Data Navigator
2
2
 
3
3
  ![Data Navigator provides visualization toolkits with rich, accessible navigation structures, robust input handling, and flexible, semantic rendering.](https://raw.githubusercontent.com/cmudig/data-navigator/main/assets/data_navigator.png)
4
4
 
5
5
  Data Navigator is a JavaScript library that allows for navigation of data structures. Data Navigator makes png, svg, canvas, and even webgl graphics accessible to a wide array of assistive technologies and input modalities.
6
6
 
7
+ Check out [our online, interactive demo](http://dig.cmu.edu/data-navigator/) for a video introduction and to try out Data Navigator hands-on.
8
+
9
+ ## Data Navigator's approach
10
+
7
11
  Data Navigator has abstracted navigation into commands, which enables it to easily receive input from screen readers and keyboards to more interesting modalities like touch and mouse swiping, spoken commands, hand gestures, and even fabricated or totally novel interfaces, like bananas.
8
12
 
9
13
  ![Image in two parts. First part: Inputs: A. Hand swiping. B: Speaking "left." C. A hand gesture on camera. D. Bananas. Second part: Output: (focus moves left) A focus indicator has moved on a bar chart from one stacked bar to another on its left.](https://raw.githubusercontent.com/cmudig/data-navigator/main/assets/inputs.png)
@@ -22,25 +26,30 @@ Visit [our landing page](http://dig.cmu.edu/data-navigator/) to try our demo, wh
22
26
 
23
27
  We also have [a vega-lite demo online](https://dig.cmu.edu/data-navigator/vega-lite.html), which (under the hood) shows how someone could write one schema that serves any chart in an ecosystem.
24
28
 
25
- ## Approach
26
- Data Navigator is organized into 3 separately composable modules: the first is a graph-based *structure* of nodes and edges, the second handles *input* and navigation logic, and the third *renders* the structure. These may be leveraged together or independently. Read our paper to learn more!
29
+ ## System design
30
+
31
+ Data Navigator is organized into 3 separately composable modules: the first is a graph-based _structure_ of nodes and edges, the second handles _input_ and navigation logic, and the third _renders_ the structure. These may be leveraged together or independently. Read our paper to learn more!
27
32
 
28
33
  ## Getting started
34
+
29
35
  You can install or use both esm and cjs modules in a variety of ways, in addition to importing all of data-navigator or just one part.
36
+
30
37
  ```
31
38
  # to install into a project
32
39
  npm install data-navigator
33
40
  ```
41
+
34
42
  ```js
35
43
  // to use it in a .js or .ts file
36
- import { default as dataNavigator } from 'data-navigator'
37
- console.log(dataNavigator)
44
+ import { default as dataNavigator } from 'data-navigator';
45
+ console.log(dataNavigator);
38
46
  ```
47
+
39
48
  ```html
40
49
  <!-- and even as a script tag module loaded from a cdn -->
41
50
  <script type="module">
42
- import dataNavigator from "https://cdn.jsdelivr.net/npm/data-navigator@1.0.0/dist/index.mjs"
43
- console.log(dataNavigator)
51
+ import dataNavigator from 'https://cdn.jsdelivr.net/npm/data-navigator@1.0.0/dist/index.mjs';
52
+ console.log(dataNavigator);
44
53
  </script>
45
54
  ```
46
55
 
@@ -48,7 +57,7 @@ console.log(dataNavigator)
48
57
 
49
58
  Data-Navigator was developed at CMU's [Data Interaction Group](https://dig.cmu.edu/) (CMU DIG), primarily by [Frank Elavsky](https://frank.computer).
50
59
 
51
- ## Citing Data-Navigator
60
+ ## Citing Data Navigator
52
61
 
53
62
  ```bib
54
63
  @article{2023-data-navigator,
@@ -57,4 +66,4 @@ Data-Navigator was developed at CMU's [Data Interaction Group](https://dig.cmu.e
57
66
  title = {{Data Navigator:} An Accessibility-Centered Data Navigation Toolkit},
58
67
  journal = {{IEEE} {VIS}}
59
68
  }
60
- ```
69
+ ```
package/dist/index.js CHANGED
@@ -523,6 +523,12 @@ var input_default = function(options) {
523
523
  };
524
524
  // src/rendering.ts
525
525
  var rendering_default = function(options) {
526
+ var setActiveDescendant = function(e) {
527
+ renderer.wrapper.setAttribute("aria-activedescendant", e.srcElement.id);
528
+ };
529
+ var removeActiveDescendant = function() {
530
+ renderer.wrapper.setAttribute("aria-activedescendant", "");
531
+ };
526
532
  var renderer = {};
527
533
  var initialized = false;
528
534
  var defaults = {
@@ -540,6 +546,7 @@ var rendering_default = function(options) {
540
546
  defaults.existingElement = options.defaults.existingElement ? _object_spread({}, defaults.existingElement, options.defaults.existingElement) : defaults.existingElement;
541
547
  }
542
548
  renderer.initialize = function() {
549
+ var _options_exitElement;
543
550
  if (initialized) {
544
551
  console.error("The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ".concat(options.suffixId, ". No further action was taken."));
545
552
  return;
@@ -558,6 +565,9 @@ var rendering_default = function(options) {
558
565
  }
559
566
  renderer.wrapper = document.createElement("div");
560
567
  renderer.wrapper.id = "dn-wrapper-" + options.suffixId;
568
+ renderer.wrapper.setAttribute("role", "application");
569
+ renderer.wrapper.setAttribute("aria-label", options.root.description || "Data navigation structure");
570
+ renderer.wrapper.setAttribute("aria-activedescendant", "");
561
571
  renderer.wrapper.classList.add("dn-wrapper");
562
572
  renderer.wrapper.style.width = options.root && options.root.width ? options.root.width : "100%";
563
573
  if (options.root && options.root.height) {
@@ -577,7 +587,7 @@ var rendering_default = function(options) {
577
587
  renderer.wrapper.appendChild(renderer.entryButton);
578
588
  }
579
589
  renderer.root.appendChild(renderer.wrapper);
580
- if (options.exitElement && options.exitElement.include) {
590
+ if ((_options_exitElement = options.exitElement) === null || _options_exitElement === void 0 ? void 0 : _options_exitElement.include) {
581
591
  renderer.exitElement = document.createElement("div");
582
592
  renderer.exitElement.id = "dn-exit-" + options.suffixId;
583
593
  renderer.exitElement.classList.add("dn-exit-position");
@@ -587,15 +597,17 @@ var rendering_default = function(options) {
587
597
  renderer.exitElement.setAttribute("tabindex", "-1");
588
598
  renderer.exitElement.style.display = "none";
589
599
  renderer.exitElement.addEventListener("focus", function(e) {
600
+ var _options_exitElement_callbacks, _options_exitElement;
590
601
  renderer.exitElement.style.display = "block";
591
602
  renderer.clearStructure();
592
- if (options.exitElement.callbacks && options.exitElement.callbacks.focus) {
603
+ if ((_options_exitElement = options.exitElement) === null || _options_exitElement === void 0 ? void 0 : (_options_exitElement_callbacks = _options_exitElement.callbacks) === null || _options_exitElement_callbacks === void 0 ? void 0 : _options_exitElement_callbacks.focus) {
593
604
  options.exitElement.callbacks.focus(e);
594
605
  }
595
606
  });
596
607
  renderer.exitElement.addEventListener("blur", function(e) {
608
+ var _options_exitElement_callbacks, _options_exitElement;
597
609
  renderer.exitElement.style.display = "none";
598
- if (options.exitElement.callbacks && options.exitElement.callbacks.blur) {
610
+ if ((_options_exitElement = options.exitElement) === null || _options_exitElement === void 0 ? void 0 : (_options_exitElement_callbacks = _options_exitElement.callbacks) === null || _options_exitElement_callbacks === void 0 ? void 0 : _options_exitElement_callbacks.blur) {
599
611
  options.exitElement.callbacks.blur(e);
600
612
  }
601
613
  });
@@ -605,7 +617,7 @@ var rendering_default = function(options) {
605
617
  return renderer.root;
606
618
  };
607
619
  renderer.render = function(nodeData) {
608
- var id = nodeData.renderId;
620
+ var id = nodeData.renderId + "";
609
621
  var d = options.elementData[id];
610
622
  if (!d) {
611
623
  console.warn("Render data not found with renderId: ".concat(id, ". Failed to render."));
@@ -644,7 +656,9 @@ var rendering_default = function(options) {
644
656
  node.style.height = height + "px";
645
657
  node.style.left = x + "px";
646
658
  node.style.top = y + "px";
647
- node.setAttribute("tabindex", "-1");
659
+ node.setAttribute("tabindex", "0");
660
+ node.addEventListener("focus", setActiveDescendant);
661
+ node.addEventListener("blur", removeActiveDescendant);
648
662
  var nodeText = document.createElement(resolveProp("semantics", "elementType"));
649
663
  var attributes = resolveProp("semantics", "attributes");
650
664
  if (typeof attributes === "object") {
@@ -671,8 +685,8 @@ var rendering_default = function(options) {
671
685
  svg.setAttribute("width", totalWidth + "");
672
686
  svg.setAttribute("height", totalHeight + "");
673
687
  svg.setAttribute("viewBox", "0 0 ".concat(totalWidth, " ").concat(totalHeight));
674
- svg.style.left = -x + "";
675
- svg.style.top = -y + "";
688
+ svg.style.left = -x + "px";
689
+ svg.style.top = -y + "px";
676
690
  svg.classList.add("dn-node-svg");
677
691
  svg.setAttribute("role", "presentation");
678
692
  svg.setAttribute("focusable", "false");
@@ -687,7 +701,12 @@ var rendering_default = function(options) {
687
701
  };
688
702
  renderer.remove = function(renderId) {
689
703
  var node = document.getElementById(renderId);
704
+ if (renderer.wrapper.getAttribute("aria-activedescendant") === renderId) {
705
+ renderer.wrapper.setAttribute("aria-activedescendant", "");
706
+ }
690
707
  if (node) {
708
+ node.removeEventListener("focus", setActiveDescendant);
709
+ node.removeEventListener("blur", removeActiveDescendant);
691
710
  node.remove();
692
711
  }
693
712
  };
package/dist/index.mjs CHANGED
@@ -393,6 +393,12 @@ var input_default = (options) => {
393
393
 
394
394
  // src/rendering.ts
395
395
  var rendering_default = (options) => {
396
+ const setActiveDescendant = (e) => {
397
+ renderer.wrapper.setAttribute("aria-activedescendant", e.srcElement.id);
398
+ };
399
+ const removeActiveDescendant = () => {
400
+ renderer.wrapper.setAttribute("aria-activedescendant", "");
401
+ };
396
402
  let renderer = {};
397
403
  let initialized = false;
398
404
  let defaults = {
@@ -432,6 +438,9 @@ var rendering_default = (options) => {
432
438
  }
433
439
  renderer.wrapper = document.createElement("div");
434
440
  renderer.wrapper.id = "dn-wrapper-" + options.suffixId;
441
+ renderer.wrapper.setAttribute("role", "application");
442
+ renderer.wrapper.setAttribute("aria-label", options.root.description || "Data navigation structure");
443
+ renderer.wrapper.setAttribute("aria-activedescendant", "");
435
444
  renderer.wrapper.classList.add("dn-wrapper");
436
445
  renderer.wrapper.style.width = options.root && options.root.width ? options.root.width : "100%";
437
446
  if (options.root && options.root.height) {
@@ -451,7 +460,7 @@ var rendering_default = (options) => {
451
460
  renderer.wrapper.appendChild(renderer.entryButton);
452
461
  }
453
462
  renderer.root.appendChild(renderer.wrapper);
454
- if (options.exitElement && options.exitElement.include) {
463
+ if (options.exitElement?.include) {
455
464
  renderer.exitElement = document.createElement("div");
456
465
  renderer.exitElement.id = "dn-exit-" + options.suffixId;
457
466
  renderer.exitElement.classList.add("dn-exit-position");
@@ -463,13 +472,13 @@ var rendering_default = (options) => {
463
472
  renderer.exitElement.addEventListener("focus", (e) => {
464
473
  renderer.exitElement.style.display = "block";
465
474
  renderer.clearStructure();
466
- if (options.exitElement.callbacks && options.exitElement.callbacks.focus) {
475
+ if (options.exitElement?.callbacks?.focus) {
467
476
  options.exitElement.callbacks.focus(e);
468
477
  }
469
478
  });
470
479
  renderer.exitElement.addEventListener("blur", (e) => {
471
480
  renderer.exitElement.style.display = "none";
472
- if (options.exitElement.callbacks && options.exitElement.callbacks.blur) {
481
+ if (options.exitElement?.callbacks?.blur) {
473
482
  options.exitElement.callbacks.blur(e);
474
483
  }
475
484
  });
@@ -479,7 +488,7 @@ var rendering_default = (options) => {
479
488
  return renderer.root;
480
489
  };
481
490
  renderer.render = (nodeData) => {
482
- const id = nodeData.renderId;
491
+ const id = nodeData.renderId + "";
483
492
  let d = options.elementData[id];
484
493
  if (!d) {
485
494
  console.warn(`Render data not found with renderId: ${id}. Failed to render.`);
@@ -518,7 +527,9 @@ var rendering_default = (options) => {
518
527
  node.style.height = height + "px";
519
528
  node.style.left = x + "px";
520
529
  node.style.top = y + "px";
521
- node.setAttribute("tabindex", "-1");
530
+ node.setAttribute("tabindex", "0");
531
+ node.addEventListener("focus", setActiveDescendant);
532
+ node.addEventListener("blur", removeActiveDescendant);
522
533
  const nodeText = document.createElement(resolveProp("semantics", "elementType"));
523
534
  const attributes = resolveProp("semantics", "attributes");
524
535
  if (typeof attributes === "object") {
@@ -547,8 +558,8 @@ var rendering_default = (options) => {
547
558
  svg.setAttribute("width", totalWidth + "");
548
559
  svg.setAttribute("height", totalHeight + "");
549
560
  svg.setAttribute("viewBox", `0 0 ${totalWidth} ${totalHeight}`);
550
- svg.style.left = -x + "";
551
- svg.style.top = -y + "";
561
+ svg.style.left = -x + "px";
562
+ svg.style.top = -y + "px";
552
563
  svg.classList.add("dn-node-svg");
553
564
  svg.setAttribute("role", "presentation");
554
565
  svg.setAttribute("focusable", "false");
@@ -563,7 +574,12 @@ var rendering_default = (options) => {
563
574
  };
564
575
  renderer.remove = (renderId) => {
565
576
  const node = document.getElementById(renderId);
577
+ if (renderer.wrapper.getAttribute("aria-activedescendant") === renderId) {
578
+ renderer.wrapper.setAttribute("aria-activedescendant", "");
579
+ }
566
580
  if (node) {
581
+ node.removeEventListener("focus", setActiveDescendant);
582
+ node.removeEventListener("blur", removeActiveDescendant);
567
583
  node.remove();
568
584
  }
569
585
  };
package/dist/rendering.js CHANGED
@@ -1 +1 @@
1
- function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(t){if(Array.isArray(t))return e(t)}function n(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function r(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var i=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){i=i.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}i.forEach(function(t){n(e,t,r[t])})}return e}function a(e){return t(e)||r(e)||o(e)||i()}function o(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}var l=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var m=function(e,t){for(var n in t)l(e,n,{get:t[n],enumerable:!0})},f=function(e,t,n,r){var i=true,s=false,a=undefined;if(t&&typeof t=="object"||typeof t=="function")try{var o=function(){var i=f.value;!d.call(e,i)&&i!==n&&l(e,i,{get:function(){return t[i]},enumerable:!(r=c(t,i))||r.enumerable})};for(var m=u(t)[Symbol.iterator](),f;!(i=(f=m.next()).done);i=true)o()}catch(e){s=true;a=e}finally{try{if(!i&&m.return!=null){m.return()}}finally{if(s){throw a}}}return e};var p=function(e){return f(l({},"__esModule",{value:!0}),e)};var b={};m(b,{default:function(){return x}});module.exports=p(b);var y={cssClass:"",dimensions:{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:{useForDimensions:!1,dimensions:void 0}};var x=function(e){var t={},n=!1,r={cssClass:y.cssClass,dimensions:s({},y.dimensions),semantics:s({},y.semantics),parentSemantics:s({},y.parentSemantics),existingElement:s({},y.existingElement)};return e.defaults&&(r.cssClass=e.defaults.cssClass||r.cssClass,r.dimensions=e.defaults.dimensions?s({},r.dimensions,e.defaults.dimensions):r.dimensions,r.semantics=e.defaults.semantics?s({},r.semantics,e.defaults.semantics):r.semantics,r.parentSemantics=e.defaults.parentSemantics?s({},r.parentSemantics,e.defaults.parentSemantics):r.parentSemantics,r.existingElement=e.defaults.existingElement?s({},r.existingElement,e.defaults.existingElement):r.existingElement),t.initialize=function(){if(n){console.error("The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ".concat(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.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),e.exitElement&&e.exitElement.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",function(n){t.exitElement.style.display="block",t.clearStructure(),e.exitElement.callbacks&&e.exitElement.callbacks.focus&&e.exitElement.callbacks.focus(n)}),t.exitElement.addEventListener("blur",function(n){t.exitElement.style.display="none",e.exitElement.callbacks&&e.exitElement.callbacks.blur&&e.exitElement.callbacks.blur(n)}),t.root.appendChild(t.exitElement)),n=!0,t.root},t.render=function(i){var s=i.renderId,a=e.elementData[s];if(!a){console.warn("Render data not found with renderId: ".concat(s,". Failed to render."));return}if(!n){console.error("render() was called before initialize(), renderer must be initialized first.");return}var o=!1,l={},c=function(e,t,n){var s=a[e]||r[e],c=n&&o?l[t]:s[t],u=r[e][t];return typeof s=="function"?s(a,i.datum):typeof c=="function"?c(a,i.datum):c||u||(t?void 0:s)};o=c("existingElement","useForDimensions"),l=c("existingElement","dimensions");var u=parseFloat(c("dimensions","width",!0)||0),d=parseFloat(c("dimensions","height",!0)||0),m=parseFloat(c("dimensions","x",!0)||0),f=parseFloat(c("dimensions","y",!0)||0),p=document.createElement(c("parentSemantics","elementType")),b=c("parentSemantics","attributes");typeof b=="object"&&Object.keys(b).forEach(function(e){p.setAttribute(e,b[e])}),p.setAttribute("role",c("parentSemantics","role")),p.id=s,p.classList.add("dn-node"),p.classList.add(c("cssClass")),p.style.width=u+"px",p.style.height=d+"px",p.style.left=m+"px",p.style.top=f+"px",p.setAttribute("tabindex","-1");var y=document.createElement(c("semantics","elementType")),x=c("semantics","attributes");typeof x=="object"&&Object.keys(x).forEach(function(e){p.setAttribute(e,x[e])}),y.setAttribute("role",c("semantics","role")),y.classList.add("dn-node-text"),a.showText&&(y.innerText=a.semantics.label);var v=c("semantics","label");v||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),y.setAttribute("aria-label",v),p.appendChild(y);var h=c("dimensions","path");if(h){var E=u+m+10,g=d+f+10,w=document.createElementNS("http://www.w3.org/2000/svg","svg");w.setAttribute("width",E+""),w.setAttribute("height",g+""),w.setAttribute("viewBox","0 0 ".concat(E," ").concat(g)),w.style.left=-m+"",w.style.top=-f+"",w.classList.add("dn-node-svg"),w.setAttribute("role","presentation"),w.setAttribute("focusable","false");var A=document.createElementNS("http://www.w3.org/2000/svg","path");A.setAttribute("d",h),A.classList.add("dn-node-path"),w.appendChild(A),p.appendChild(w)}return t.wrapper.appendChild(p),p},t.remove=function(e){var t=document.getElementById(e);t&&t.remove()},t.clearStructure=function(){a(t.wrapper.children).forEach(function(e){t.entryButton&&t.entryButton===e||t.remove(e.id)})},t};
1
+ function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(t){if(Array.isArray(t))return e(t)}function n(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function r(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var i=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){i=i.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}i.forEach(function(t){n(e,t,r[t])})}return e}function s(e){return t(e)||r(e)||o(e)||i()}function o(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=function(e,t){for(var n in t)l(e,n,{get:t[n],enumerable:!0})},m=function(e,t,n,r){var i=true,a=false,s=undefined;if(t&&typeof t=="object"||typeof t=="function")try{var o=function(){var i=m.value;!d.call(e,i)&&i!==n&&l(e,i,{get:function(){return t[i]},enumerable:!(r=u(t,i))||r.enumerable})};for(var f=c(t)[Symbol.iterator](),m;!(i=(m=f.next()).done);i=true)o()}catch(e){a=true;s=e}finally{try{if(!i&&f.return!=null){f.return()}}finally{if(a){throw s}}}return e};var p=function(e){return m(l({},"__esModule",{value:!0}),e)};var b={};f(b,{default:function(){return v}});module.exports=p(b);var y={cssClass:"",dimensions:{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:{useForDimensions:!1,dimensions:void 0}};var v=function(e){var t=function(e){r.wrapper.setAttribute("aria-activedescendant",e.srcElement.id)},n=function(){r.wrapper.setAttribute("aria-activedescendant","")},r={},i=!1,o={cssClass:y.cssClass,dimensions:a({},y.dimensions),semantics:a({},y.semantics),parentSemantics:a({},y.parentSemantics),existingElement:a({},y.existingElement)};return e.defaults&&(o.cssClass=e.defaults.cssClass||o.cssClass,o.dimensions=e.defaults.dimensions?a({},o.dimensions,e.defaults.dimensions):o.dimensions,o.semantics=e.defaults.semantics?a({},o.semantics,e.defaults.semantics):o.semantics,o.parentSemantics=e.defaults.parentSemantics?a({},o.parentSemantics,e.defaults.parentSemantics):o.parentSemantics,o.existingElement=e.defaults.existingElement?a({},o.existingElement,e.defaults.existingElement):o.existingElement),r.initialize=function(){var t;if(i){console.error("The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ".concat(e.suffixId,". No further action was taken."));return}if(e.root&&document.getElementById(e.root.id))r.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(r.root.style.position="relative",r.root.classList.add("dn-root"),!e.suffixId){console.error("No suffix id found: options.suffixId must be specified.");return}return r.wrapper=document.createElement("div"),r.wrapper.id="dn-wrapper-"+e.suffixId,r.wrapper.setAttribute("role","application"),r.wrapper.setAttribute("aria-label",e.root.description||"Data navigation structure"),r.wrapper.setAttribute("aria-activedescendant",""),r.wrapper.classList.add("dn-wrapper"),r.wrapper.style.width=e.root&&e.root.width?e.root.width:"100%",e.root&&e.root.height&&(r.wrapper.style.height=e.root.height),e.entryButton&&e.entryButton.include&&(r.entryButton=document.createElement("button"),r.entryButton.id="dn-entry-button-"+e.suffixId,r.entryButton.classList.add("dn-entry-button"),r.entryButton.innerText="Enter navigation area",e.entryButton.callbacks&&e.entryButton.callbacks.click&&r.entryButton.addEventListener("click",e.entryButton.callbacks.click),e.entryButton.callbacks&&e.entryButton.callbacks.focus&&r.entryButton.addEventListener("focus",e.entryButton.callbacks.focus),r.wrapper.appendChild(r.entryButton)),r.root.appendChild(r.wrapper),((t=e.exitElement)===null||t===void 0?void 0:t.include)&&(r.exitElement=document.createElement("div"),r.exitElement.id="dn-exit-"+e.suffixId,r.exitElement.classList.add("dn-exit-position"),r.exitElement.innerText="End of data structure.",r.exitElement.setAttribute("aria-label","End of data structure."),r.exitElement.setAttribute("role","note"),r.exitElement.setAttribute("tabindex","-1"),r.exitElement.style.display="none",r.exitElement.addEventListener("focus",function(t){var n,i;r.exitElement.style.display="block",r.clearStructure(),((i=e.exitElement)===null||i===void 0?void 0:(n=i.callbacks)===null||n===void 0?void 0:n.focus)&&e.exitElement.callbacks.focus(t)}),r.exitElement.addEventListener("blur",function(t){var n,i;r.exitElement.style.display="none",((i=e.exitElement)===null||i===void 0?void 0:(n=i.callbacks)===null||n===void 0?void 0:n.blur)&&e.exitElement.callbacks.blur(t)}),r.root.appendChild(r.exitElement)),i=!0,r.root},r.render=function(a){var s=a.renderId+"",l=e.elementData[s];if(!l){console.warn("Render data not found with renderId: ".concat(s,". Failed to render."));return}if(!i){console.error("render() was called before initialize(), renderer must be initialized first.");return}var u=!1,c={},d=function(e,t,n){var r=l[e]||o[e],i=n&&u?c[t]:r[t],s=o[e][t];return typeof r=="function"?r(l,a.datum):typeof i=="function"?i(l,a.datum):i||s||(t?void 0:r)};u=d("existingElement","useForDimensions"),c=d("existingElement","dimensions");var f=parseFloat(d("dimensions","width",!0)||0),m=parseFloat(d("dimensions","height",!0)||0),p=parseFloat(d("dimensions","x",!0)||0),b=parseFloat(d("dimensions","y",!0)||0),y=document.createElement(d("parentSemantics","elementType")),v=d("parentSemantics","attributes");typeof v=="object"&&Object.keys(v).forEach(function(e){y.setAttribute(e,v[e])}),y.setAttribute("role",d("parentSemantics","role")),y.id=s,y.classList.add("dn-node"),y.classList.add(d("cssClass")),y.style.width=f+"px",y.style.height=m+"px",y.style.left=p+"px",y.style.top=b+"px",y.setAttribute("tabindex","0"),y.addEventListener("focus",t),y.addEventListener("blur",n);var x=document.createElement(d("semantics","elementType")),E=d("semantics","attributes");typeof E=="object"&&Object.keys(E).forEach(function(e){y.setAttribute(e,E[e])}),x.setAttribute("role",d("semantics","role")),x.classList.add("dn-node-text"),l.showText&&(x.innerText=l.semantics.label);var h=d("semantics","label");h||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),x.setAttribute("aria-label",h),y.appendChild(x);var w=d("dimensions","path");if(w){var g=f+p+10,A=m+b+10,S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("width",g+""),S.setAttribute("height",A+""),S.setAttribute("viewBox","0 0 ".concat(g," ").concat(A)),S.style.left=-p+"px",S.style.top=-b+"px",S.classList.add("dn-node-svg"),S.setAttribute("role","presentation"),S.setAttribute("focusable","false");var O=document.createElementNS("http://www.w3.org/2000/svg","path");O.setAttribute("d",w),O.classList.add("dn-node-path"),S.appendChild(O),y.appendChild(S)}return r.wrapper.appendChild(y),y},r.remove=function(e){var i=document.getElementById(e);r.wrapper.getAttribute("aria-activedescendant")===e&&r.wrapper.setAttribute("aria-activedescendant",""),i&&(i.removeEventListener("focus",t),i.removeEventListener("blur",n),i.remove())},r.clearStructure=function(){s(r.wrapper.children).forEach(function(e){r.entryButton&&r.entryButton===e||r.remove(e.id)})},r};
@@ -1 +1 @@
1
- import{d as m}from"./chunk-GP5LYFFJ.mjs";var L=t=>{let e={},x=!1,n={cssClass:m.cssClass,dimensions:{...m.dimensions},semantics:{...m.semantics},parentSemantics:{...m.parentSemantics},existingElement:{...m.existingElement}};return t.defaults&&(n.cssClass=t.defaults.cssClass||n.cssClass,n.dimensions=t.defaults.dimensions?{...n.dimensions,...t.defaults.dimensions}:n.dimensions,n.semantics=t.defaults.semantics?{...n.semantics,...t.defaults.semantics}:n.semantics,n.parentSemantics=t.defaults.parentSemantics?{...n.parentSemantics,...t.defaults.parentSemantics}:n.parentSemantics,n.existingElement=t.defaults.existingElement?{...n.existingElement,...t.defaults.existingElement}:n.existingElement),e.initialize=()=>{if(x){console.error(`The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ${t.suffixId}. No further action was taken.`);return}if(t.root&&document.getElementById(t.root.id))e.root=document.getElementById(t.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(e.root.style.position="relative",e.root.classList.add("dn-root"),!t.suffixId){console.error("No suffix id found: options.suffixId must be specified.");return}return e.wrapper=document.createElement("div"),e.wrapper.id="dn-wrapper-"+t.suffixId,e.wrapper.classList.add("dn-wrapper"),e.wrapper.style.width=t.root&&t.root.width?t.root.width:"100%",t.root&&t.root.height&&(e.wrapper.style.height=t.root.height),t.entryButton&&t.entryButton.include&&(e.entryButton=document.createElement("button"),e.entryButton.id="dn-entry-button-"+t.suffixId,e.entryButton.classList.add("dn-entry-button"),e.entryButton.innerText="Enter navigation area",t.entryButton.callbacks&&t.entryButton.callbacks.click&&e.entryButton.addEventListener("click",t.entryButton.callbacks.click),t.entryButton.callbacks&&t.entryButton.callbacks.focus&&e.entryButton.addEventListener("focus",t.entryButton.callbacks.focus),e.wrapper.appendChild(e.entryButton)),e.root.appendChild(e.wrapper),t.exitElement&&t.exitElement.include&&(e.exitElement=document.createElement("div"),e.exitElement.id="dn-exit-"+t.suffixId,e.exitElement.classList.add("dn-exit-position"),e.exitElement.innerText="End of data structure.",e.exitElement.setAttribute("aria-label","End of data structure."),e.exitElement.setAttribute("role","note"),e.exitElement.setAttribute("tabindex","-1"),e.exitElement.style.display="none",e.exitElement.addEventListener("focus",r=>{e.exitElement.style.display="block",e.clearStructure(),t.exitElement.callbacks&&t.exitElement.callbacks.focus&&t.exitElement.callbacks.focus(r)}),e.exitElement.addEventListener("blur",r=>{e.exitElement.style.display="none",t.exitElement.callbacks&&t.exitElement.callbacks.blur&&t.exitElement.callbacks.blur(r)}),e.root.appendChild(e.exitElement)),x=!0,e.root},e.render=r=>{let u=r.renderId,o=t.elementData[u];if(!o){console.warn(`Render data not found with renderId: ${u}. Failed to render.`);return}if(!x){console.error("render() was called before initialize(), renderer must be initialized first.");return}let g=!1,w={},s=(a,c,l)=>{let d=o[a]||n[a],p=l&&g?w[c]:d[c],S=n[a][c];return typeof d=="function"?d(o,r.datum):typeof p=="function"?p(o,r.datum):p||S||(c?void 0:d)};g=s("existingElement","useForDimensions"),w=s("existingElement","dimensions");let B=parseFloat(s("dimensions","width",!0)||0),k=parseFloat(s("dimensions","height",!0)||0),b=parseFloat(s("dimensions","x",!0)||0),y=parseFloat(s("dimensions","y",!0)||0),i=document.createElement(s("parentSemantics","elementType")),E=s("parentSemantics","attributes");typeof E=="object"&&Object.keys(E).forEach(a=>{i.setAttribute(a,E[a])}),i.setAttribute("role",s("parentSemantics","role")),i.id=u,i.classList.add("dn-node"),i.classList.add(s("cssClass")),i.style.width=B+"px",i.style.height=k+"px",i.style.left=b+"px",i.style.top=y+"px",i.setAttribute("tabindex","-1");let f=document.createElement(s("semantics","elementType")),h=s("semantics","attributes");typeof h=="object"&&Object.keys(h).forEach(a=>{i.setAttribute(a,h[a])}),f.setAttribute("role",s("semantics","role")),f.classList.add("dn-node-text"),o.showText&&(f.innerText=o.semantics.label);let v=s("semantics","label");v||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),f.setAttribute("aria-label",v),i.appendChild(f);let A=s("dimensions","path");if(A){let a=B+b+10,c=k+y+10,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("width",a+""),l.setAttribute("height",c+""),l.setAttribute("viewBox",`0 0 ${a} ${c}`),l.style.left=-b+"",l.style.top=-y+"",l.classList.add("dn-node-svg"),l.setAttribute("role","presentation"),l.setAttribute("focusable","false");let d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",A),d.classList.add("dn-node-path"),l.appendChild(d),i.appendChild(l)}return e.wrapper.appendChild(i),i},e.remove=r=>{let u=document.getElementById(r);u&&u.remove()},e.clearStructure=()=>{[...e.wrapper.children].forEach(r=>{e.entryButton&&e.entryButton===r||e.remove(r.id)})},e};export{L as default};
1
+ import{d as m}from"./chunk-GP5LYFFJ.mjs";var T=t=>{let w=r=>{e.wrapper.setAttribute("aria-activedescendant",r.srcElement.id)},g=()=>{e.wrapper.setAttribute("aria-activedescendant","")},e={},b=!1,s={cssClass:m.cssClass,dimensions:{...m.dimensions},semantics:{...m.semantics},parentSemantics:{...m.parentSemantics},existingElement:{...m.existingElement}};return t.defaults&&(s.cssClass=t.defaults.cssClass||s.cssClass,s.dimensions=t.defaults.dimensions?{...s.dimensions,...t.defaults.dimensions}:s.dimensions,s.semantics=t.defaults.semantics?{...s.semantics,...t.defaults.semantics}:s.semantics,s.parentSemantics=t.defaults.parentSemantics?{...s.parentSemantics,...t.defaults.parentSemantics}:s.parentSemantics,s.existingElement=t.defaults.existingElement?{...s.existingElement,...t.defaults.existingElement}:s.existingElement),e.initialize=()=>{if(b){console.error(`The renderer wrapper has already been initialized successfully, RenderingOptions.suffixId is: ${t.suffixId}. No further action was taken.`);return}if(t.root&&document.getElementById(t.root.id))e.root=document.getElementById(t.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(e.root.style.position="relative",e.root.classList.add("dn-root"),!t.suffixId){console.error("No suffix id found: options.suffixId must be specified.");return}return e.wrapper=document.createElement("div"),e.wrapper.id="dn-wrapper-"+t.suffixId,e.wrapper.setAttribute("role","application"),e.wrapper.setAttribute("aria-label",t.root.description||"Data navigation structure"),e.wrapper.setAttribute("aria-activedescendant",""),e.wrapper.classList.add("dn-wrapper"),e.wrapper.style.width=t.root&&t.root.width?t.root.width:"100%",t.root&&t.root.height&&(e.wrapper.style.height=t.root.height),t.entryButton&&t.entryButton.include&&(e.entryButton=document.createElement("button"),e.entryButton.id="dn-entry-button-"+t.suffixId,e.entryButton.classList.add("dn-entry-button"),e.entryButton.innerText="Enter navigation area",t.entryButton.callbacks&&t.entryButton.callbacks.click&&e.entryButton.addEventListener("click",t.entryButton.callbacks.click),t.entryButton.callbacks&&t.entryButton.callbacks.focus&&e.entryButton.addEventListener("focus",t.entryButton.callbacks.focus),e.wrapper.appendChild(e.entryButton)),e.root.appendChild(e.wrapper),t.exitElement?.include&&(e.exitElement=document.createElement("div"),e.exitElement.id="dn-exit-"+t.suffixId,e.exitElement.classList.add("dn-exit-position"),e.exitElement.innerText="End of data structure.",e.exitElement.setAttribute("aria-label","End of data structure."),e.exitElement.setAttribute("role","note"),e.exitElement.setAttribute("tabindex","-1"),e.exitElement.style.display="none",e.exitElement.addEventListener("focus",r=>{e.exitElement.style.display="block",e.clearStructure(),t.exitElement?.callbacks?.focus&&t.exitElement.callbacks.focus(r)}),e.exitElement.addEventListener("blur",r=>{e.exitElement.style.display="none",t.exitElement?.callbacks?.blur&&t.exitElement.callbacks.blur(r)}),e.root.appendChild(e.exitElement)),b=!0,e.root},e.render=r=>{let d=r.renderId+"",u=t.elementData[d];if(!u){console.warn(`Render data not found with renderId: ${d}. Failed to render.`);return}if(!b){console.error("render() was called before initialize(), renderer must be initialized first.");return}let v=!1,A={},i=(a,o,l)=>{let c=u[a]||s[a],h=l&&v?A[o]:c[o],C=s[a][o];return typeof c=="function"?c(u,r.datum):typeof h=="function"?h(u,r.datum):h||C||(o?void 0:c)};v=i("existingElement","useForDimensions"),A=i("existingElement","dimensions");let B=parseFloat(i("dimensions","width",!0)||0),k=parseFloat(i("dimensions","height",!0)||0),p=parseFloat(i("dimensions","x",!0)||0),x=parseFloat(i("dimensions","y",!0)||0),n=document.createElement(i("parentSemantics","elementType")),E=i("parentSemantics","attributes");typeof E=="object"&&Object.keys(E).forEach(a=>{n.setAttribute(a,E[a])}),n.setAttribute("role",i("parentSemantics","role")),n.id=d,n.classList.add("dn-node"),n.classList.add(i("cssClass")),n.style.width=B+"px",n.style.height=k+"px",n.style.left=p+"px",n.style.top=x+"px",n.setAttribute("tabindex","0"),n.addEventListener("focus",w),n.addEventListener("blur",g);let f=document.createElement(i("semantics","elementType")),y=i("semantics","attributes");typeof y=="object"&&Object.keys(y).forEach(a=>{n.setAttribute(a,y[a])}),f.setAttribute("role",i("semantics","role")),f.classList.add("dn-node-text"),u.showText&&(f.innerText=u.semantics.label);let L=i("semantics","label");L||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),f.setAttribute("aria-label",L),n.appendChild(f);let S=i("dimensions","path");if(S){let a=B+p+10,o=k+x+10,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("width",a+""),l.setAttribute("height",o+""),l.setAttribute("viewBox",`0 0 ${a} ${o}`),l.style.left=-p+"px",l.style.top=-x+"px",l.classList.add("dn-node-svg"),l.setAttribute("role","presentation"),l.setAttribute("focusable","false");let c=document.createElementNS("http://www.w3.org/2000/svg","path");c.setAttribute("d",S),c.classList.add("dn-node-path"),l.appendChild(c),n.appendChild(l)}return e.wrapper.appendChild(n),n},e.remove=r=>{let d=document.getElementById(r);e.wrapper.getAttribute("aria-activedescendant")===r&&e.wrapper.setAttribute("aria-activedescendant",""),d&&(d.removeEventListener("focus",w),d.removeEventListener("blur",g),d.remove())},e.clearStructure=()=>{[...e.wrapper.children].forEach(r=>{e.entryButton&&e.entryButton===r||e.remove(r.id)})},e};export{T as default};
@@ -1 +1 @@
1
- import{a as R}from"./chunk-KNRZ7RNY.mjs";import{c as C}from"./chunk-GP5LYFFJ.mjs";var j=t=>{if(t.dataType==="vega-lite"||t.dataType==="vl"||t.dataType==="Vega-Lite")return w(t);console.warn("Apologies, we currently only have structure scaffolding for Vega-Lite, generic scaffolding coming soon!")},w=t=>{let L=C,r={},u={},o={},y=0,$=t.groupInclusionCriteria?t.groupInclusionCriteria:()=>!0,E=t.itemInclusionCriteria?t.itemInclusionCriteria:()=>!0,S=t.datumInclusionCriteria?t.datumInclusionCriteria:()=>!0,b=t.vegaLiteView._renderer._origin,I=t.vegaLiteView._scenegraph.root.items[0].mark.items[0],m=(e,i)=>{if(e["data-navigator-id"])return e["data-navigator-id"];let c=`dn-node-${i}-${y}`;return y++,e["data-navigator-id"]=c,c},k=e=>{let i=r[e],c=i.index,g=i.level,l=i.parent,n=[],d=l.items[c-1];if(d){let s=m(d,g);if(r[s]){let a=`${s}-${i.id}`;n.push(a),u[a]||(u[a]={source:s,target:i.id,navigationRules:["left","right"]})}}let f=l.items[c+1];if(f){let s=m(f,g);if(r[s]){let a=`${i.id}-${s}`;n.push(a),u[a]||(u[a]={source:i.id,target:s,navigationRules:["left","right"]})}}if(g==="group"&&l.items[c].items){let a=(l.items[c].items[0].mark.items[0].items||l.items[c].items)[0],v=m(a,"item");if(r[v]){let x=`${i.id}-${v}`;n.push(x),u[x]||(u[x]={source:i.id,target:v,navigationRules:["parent","child"]})}}else if(g==="item"){let s=m(l,"group");if(r[s]){let a=`${s}-${i.id}`;n.push(a),u[a]||(u[a]={source:s,target:i.id,navigationRules:["parent","child"]})}}return t.exitFunction&&(n.push("any-exit"),u["any-exit"]||(u["any-exit"]={source:t.getCurrent,target:t.exitFunction,navigationRules:["exit"]})),n.push("any-undo"),u["any-undo"]||(u["any-undo"]={source:t.getCurrent,target:t.getPrevious,navigationRules:["undo"]}),n},p=(e,i,c,g,l)=>{let n=m(e,i),d="render-"+n,f=c||[0,0];r[n]={},r[n].d={},r[n].id=n,r[n].renderId=d,r[n].index=g,r[n].level=i,r[n].parent=l,o[d]={},o[d].renderId=d,o[d].dimensions={},o[d].dimensions.x=e.bounds.x1+f[0],o[d].dimensions.y=e.bounds.y1+f[1],o[d].dimensions.width=e.bounds.x2-e.bounds.x1,o[d].dimensions.height=e.bounds.y2-e.bounds.y1,o[d].cssClass="dn-vega-lite-node",e.datum&&Object.keys(e.datum).forEach(s=>{let a=e.datum[s];S(s,a,e.datum,i,t.vegaLiteSpec)&&(r[n].d[t.keyRenamingHash&&t.keyRenamingHash[s]?t.keyRenamingHash[s]:s]=a)}),o[d].semantics={},o[d].semantics.label=t.nodeDescriber?t.nodeDescriber(r[n].d,e,i):R(r[n].d)},h=0;return I.items.forEach(e=>{if($(e,h,t.vegaLiteSpec)){p(e,"group",b,h,I);let i=0,c=e.items[0].mark.items[0].items?e.items[0].mark.items[0]:e;c.items.forEach(g=>{E(g,i,e,t.vegaLiteSpec)&&p(g,"item",b,i,c),i++})}h++}),Object.keys(r).forEach(e=>{r[e].edges=k(e)}),{nodes:r,edges:u,elementData:o,navigationRules:L}},B=t=>({});export{B as buildNodeStructure,w as buildNodeStructureFromVegaLite,j as default};
1
+ import{a as L}from"./chunk-KNRZ7RNY.mjs";import{c as C}from"./chunk-GP5LYFFJ.mjs";var j=t=>{if(t.dataType==="vega-lite"||t.dataType==="vl"||t.dataType==="Vega-Lite")return w(t);console.warn("Apologies, we currently only have structure scaffolding for Vega-Lite, generic scaffolding coming soon!")},w=t=>{let R=C,r={},u={},o={},y=0,$=t.groupInclusionCriteria?t.groupInclusionCriteria:()=>!0,E=t.itemInclusionCriteria?t.itemInclusionCriteria:()=>!0,S=t.datumInclusionCriteria?t.datumInclusionCriteria:()=>!0,b=t.vegaLiteView._renderer._origin,I=t.vegaLiteView._scenegraph.root.items[0].mark.items[0],m=(e,i)=>{if(e["data-navigator-id"])return e["data-navigator-id"];let c=`dn-node-${i}-${y}`;return y++,e["data-navigator-id"]=c,c},k=e=>{let i=r[e],c=i.index,g=i.level,l=i.parent,n=[],d=l.items[c-1];if(d){let s=m(d,g);if(r[s]){let a=`${s}-${i.id}`;n.push(a),u[a]||(u[a]={source:s,target:i.id,navigationRules:["left","right"]})}}let f=l.items[c+1];if(f){let s=m(f,g);if(r[s]){let a=`${i.id}-${s}`;n.push(a),u[a]||(u[a]={source:i.id,target:s,navigationRules:["left","right"]})}}if(g==="group"&&l.items[c].items){let a=(l.items[c].items[0].mark.items[0].items||l.items[c].items)[0],v=m(a,"item");if(r[v]){let x=`${i.id}-${v}`;n.push(x),u[x]||(u[x]={source:i.id,target:v,navigationRules:["parent","child"]})}}else if(g==="item"){let s=m(l,"group");if(r[s]){let a=`${s}-${i.id}`;n.push(a),u[a]||(u[a]={source:s,target:i.id,navigationRules:["parent","child"]})}}return t.exitFunction&&(n.push("any-exit"),u["any-exit"]||(u["any-exit"]={source:t.getCurrent,target:t.exitFunction,navigationRules:["exit"]})),n.push("any-undo"),u["any-undo"]||(u["any-undo"]={source:t.getCurrent,target:t.getPrevious,navigationRules:["undo"]}),n},p=(e,i,c,g,l)=>{let n=m(e,i),d="render-"+n,f=c||[0,0];r[n]={},r[n].d={},r[n].id=n,r[n].renderId=d,r[n].index=g,r[n].level=i,r[n].parent=l,o[d]={},o[d].renderId=d,o[d].dimensions={},o[d].dimensions.x=e.bounds.x1+f[0],o[d].dimensions.y=e.bounds.y1+f[1],o[d].dimensions.width=e.bounds.x2-e.bounds.x1,o[d].dimensions.height=e.bounds.y2-e.bounds.y1,o[d].cssClass="dn-vega-lite-node",e.datum&&Object.keys(e.datum).forEach(s=>{let a=e.datum[s];S(s,a,e.datum,i,t.vegaLiteSpec)&&(r[n].d[t.keyRenamingHash&&t.keyRenamingHash[s]?t.keyRenamingHash[s]:s]=a)}),o[d].semantics={},o[d].semantics.label=t.nodeDescriber?t.nodeDescriber(r[n].d,e,i):L(r[n].d)},h=0;return I.items.forEach(e=>{if($(e,h,t.vegaLiteSpec)){p(e,"group",b,h,I);let i=0,c=e.items[0].mark.items[0].items?e.items[0].mark.items[0]:e;c.items.forEach(g=>{E(g,i,e,t.vegaLiteSpec)&&p(g,"item",b,i,c),i++})}h++}),Object.keys(r).forEach(e=>{r[e].edges=k(e)}),{nodes:r,edges:u,elementData:o,navigationRules:R}},B=t=>({});export{B as buildNodeStructure,w as buildNodeStructureFromVegaLite,j as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "data-navigator",
3
3
  "author": "Frank Elavsky",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "main": "dist/index.jsm",
6
6
  "module": "dist/index",
7
7
  "types": "data-navigator.d.ts",