data-navigator 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,6 +30,10 @@ We also have [a vega-lite demo online](https://dig.cmu.edu/data-navigator/vega-l
30
30
 
31
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!
32
32
 
33
+ ### Types
34
+
35
+ Our types are consolidated into a single [types export file](./src/data-navigator.ts), designed (mostly) as a grammar. Each major module is broken down into subparts, each with their own types, all the way to the primitive-most types used.
36
+
33
37
  ## Getting started
34
38
 
35
39
  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.
@@ -41,14 +45,20 @@ npm install data-navigator
41
45
 
42
46
  ```js
43
47
  // to use it in a .js or .ts file
44
- import { default as dataNavigator } from 'data-navigator';
45
- console.log(dataNavigator);
48
+ import { default as dataNavigator } from "data-navigator"
49
+
50
+ // whole ecosystem
51
+ console.log("dataNavigator", dataNavigator)
52
+
53
+ // one module in the ecosystem
54
+ console.log("dataNavigator.rendering", dataNavigator.rendering)
46
55
  ```
47
56
 
48
57
  ```html
49
58
  <!-- and even as a script tag module loaded from a cdn -->
50
59
  <script type="module">
51
- import dataNavigator from 'https://cdn.jsdelivr.net/npm/data-navigator@1.0.0/dist/index.mjs';
60
+ // pay attention to the version! the latest may be higher than this example
61
+ import dataNavigator from 'https://cdn.jsdelivr.net/npm/data-navigator@1.2.4/dist/index.mjs';
52
62
  console.log(dataNavigator);
53
63
  </script>
54
64
  ```
@@ -1 +1 @@
1
- var m=(a,e)=>{let b=Object.keys(a),t="";return b.forEach(c=>{t+=`${e&&e.omitKeyNames?"":c+": "}${a[c]}. `}),t+=e&&e.semanticLabel||"Data point.",t};export{m as a};
1
+ var m=(a,e)=>{let o=Object.keys(a),t="";return o.forEach(c=>{t+=`${e&&e.omitKeyNames?"":c+": "}${a[c]}. `}),t+=e&&e.semanticLabel||"Data point.",t};export{m as a};
package/dist/input.mjs CHANGED
@@ -1 +1 @@
1
- import{a as c,b as g}from"./chunk-GP5LYFFJ.mjs";var m=r=>{let n={},u=c,a=g;return n.moveTo=e=>{let t=r.structure.nodes[e];if(t)return t},n.move=(e,t)=>{if(e){let o=r.structure.nodes[e];if(o.edges){let s=null,l=0,d=a[t];if(!d)return;let p=(f,i)=>{if(f!==t)return null;let y={target:typeof i.target=="string"?i.target:i.target(o,e),source:typeof i.source=="string"?i.source:i.source(o,e)};return y[d.direction]!==e?y[d.direction]:null};for(l=0;l<o.edges.length;l++){let f=r.structure.edges[o.edges[l]];if(f.navigationRules.forEach(i=>{s||(s=p(i,f))}),s)break}return s?n.moveTo(s):void 0}}},n.enter=()=>{if(r.entryPoint)return n.moveTo(r.entryPoint);console.error("No entry point was specified in InputOptions, returning undefined")},n.exit=()=>{if(r.exitPoint)return r.exitPoint;console.error("No exit point was specified in InputOptions, returning undefined")},n.keydownValidator=e=>{let t=u[e.code];if(t)return t},n.focus=e=>{let t=document.getElementById(e);t&&t.focus()},n.setNavigationKeyBindings=e=>{e?(u={},a=e,Object.keys(e).forEach(t=>{let o=e[t];u[o.key]=t})):(u=c,a=g)},n.setNavigationKeyBindings(r.navigationRules),n};export{m as default};
1
+ import{a as c,b as g}from"./chunk-GP5LYFFJ.mjs";var v=r=>{let n={},u=c,l=g;return n.moveTo=e=>{let t=r.structure.nodes[e];if(t)return t},n.move=(e,t)=>{if(e){let o=r.structure.nodes[e];if(o.edges){let s=null,a=0,d=l[t];if(!d)return;let y=(f,i)=>{if(f!==t)return null;let p={target:typeof i.target=="string"?i.target:i.target(o,e),source:typeof i.source=="string"?i.source:i.source(o,e)};return p[d.direction]!==e?p[d.direction]:null};for(a=0;a<o.edges.length;a++){let f=r.structure.edges[o.edges[a]];if(f.navigationRules.forEach(i=>{s||(s=y(i,f))}),s)break}return s?n.moveTo(s):void 0}}},n.enter=()=>{if(r.entryPoint)return n.moveTo(r.entryPoint);console.error("No entry point was specified in InputOptions, returning undefined")},n.exit=()=>{if(r.exitPoint)return r.exitPoint;console.error("No exit point was specified in InputOptions, returning undefined")},n.keydownValidator=e=>{let t=u[e.code];if(t)return t},n.focus=e=>{let t=document.getElementById(e);t&&t.focus()},n.setNavigationKeyBindings=e=>{e?(u={},l=e,Object.keys(e).forEach(t=>{let o=e[t];u[o.key]=t})):(u=c,l=g)},n.setNavigationKeyBindings(r.navigationRules),n};export{v as default};
@@ -1 +1 @@
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
+ import{d as m}from"./chunk-GP5LYFFJ.mjs";var O=t=>{let w=s=>{e.wrapper.setAttribute("aria-activedescendant",s.srcElement.id)},g=()=>{e.wrapper.setAttribute("aria-activedescendant","")},e={},b=!1,r={cssClass:m.cssClass,dimensions:{...m.dimensions},semantics:{...m.semantics},parentSemantics:{...m.parentSemantics},existingElement:{...m.existingElement}};return t.defaults&&(r.cssClass=t.defaults.cssClass||r.cssClass,r.dimensions=t.defaults.dimensions?{...r.dimensions,...t.defaults.dimensions}:r.dimensions,r.semantics=t.defaults.semantics?{...r.semantics,...t.defaults.semantics}:r.semantics,r.parentSemantics=t.defaults.parentSemantics?{...r.parentSemantics,...t.defaults.parentSemantics}:r.parentSemantics,r.existingElement=t.defaults.existingElement?{...r.existingElement,...t.defaults.existingElement}:r.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",s=>{e.exitElement.style.display="block",e.clearStructure(),t.exitElement?.callbacks?.focus&&t.exitElement.callbacks.focus(s)}),e.exitElement.addEventListener("blur",s=>{e.exitElement.style.display="none",t.exitElement?.callbacks?.blur&&t.exitElement.callbacks.blur(s)}),e.root.appendChild(e.exitElement)),b=!0,e.root},e.render=s=>{let d=s.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]||r[a],h=l&&v?A[o]:c[o],C=r[a][o];return typeof c=="function"?c(u,s.datum):typeof h=="function"?h(u,s.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=s=>{let d=document.getElementById(s);e.wrapper.getAttribute("aria-activedescendant")===s&&e.wrapper.setAttribute("aria-activedescendant",""),d&&(d.removeEventListener("focus",w),d.removeEventListener("blur",g),d.remove())},e.clearStructure=()=>{[...e.wrapper.children].forEach(s=>{e.entryButton&&e.entryButton===s||e.remove(s.id)})},e};export{O as default};
@@ -1,3 +1,4 @@
1
+ import type { DatumObject, NavigationRules, RenderObject } from './data-navigator';
1
2
  export declare const defaultKeyBindings: DatumObject;
2
3
  export declare const GenericFullNavigationRules: NavigationRules;
3
4
  export declare const GenericLimitedNavigationRules: NavigationRules;
@@ -1,13 +1,13 @@
1
- type StructureOptions = {
1
+ export type StructureOptions = {
2
2
  [key: string | number]: any;
3
3
  };
4
- type InputOptions = {
4
+ export type InputOptions = {
5
5
  structure: Structure;
6
6
  navigationRules: NavigationRules;
7
7
  entryPoint?: NodeId;
8
8
  exitPoint?: RenderId;
9
9
  };
10
- type RenderingOptions = {
10
+ export type RenderingOptions = {
11
11
  elementData: ElementData | Nodes;
12
12
  suffixId: string;
13
13
  root: RootObject;
@@ -15,37 +15,37 @@ type RenderingOptions = {
15
15
  entryButton?: EntryObject;
16
16
  exitElement?: ExitObject;
17
17
  };
18
- type Structure = {
18
+ export type Structure = {
19
19
  nodes: Nodes;
20
20
  edges: Edges;
21
21
  navigationRules?: NavigationRules;
22
22
  elementData?: ElementData;
23
23
  };
24
- type Nodes = Record<NodeId, NodeObject>;
25
- type Edges = Record<EdgeId, EdgeObject>;
26
- type NavigationRules = Record<NavId, NavObject>;
27
- type ElementData = Record<RenderId, RenderObject>;
28
- type EdgeList = Array<EdgeId>;
29
- type NavigationList = Array<NavId>;
30
- type Semantics = ((RenderObject?: any, DatumObject?: any) => SemanticsObject) | SemanticsObject;
31
- type Dimensions = ((RenderObject?: any, DatumObject?: any) => DimensionsObject) | DimensionsObject;
32
- type Attributes = ((RenderObject?: any, DatumObject?: any) => AttributesObject) | AttributesObject;
33
- type NodeObject = {
24
+ export type Nodes = Record<NodeId, NodeObject>;
25
+ export type Edges = Record<EdgeId, EdgeObject>;
26
+ export type NavigationRules = Record<NavId, NavObject>;
27
+ export type ElementData = Record<RenderId, RenderObject>;
28
+ export type EdgeList = Array<EdgeId>;
29
+ export type NavigationList = Array<NavId>;
30
+ export type Semantics = ((RenderObject?: any, DatumObject?: any) => SemanticsObject) | SemanticsObject;
31
+ export type Dimensions = ((RenderObject?: any, DatumObject?: any) => DimensionsObject) | DimensionsObject;
32
+ export type Attributes = ((RenderObject?: any, DatumObject?: any) => AttributesObject) | AttributesObject;
33
+ export type NodeObject = {
34
34
  id: NodeId;
35
35
  edges: EdgeList;
36
36
  renderId?: RenderId;
37
37
  [key: string | number]: any;
38
38
  };
39
- type EdgeObject = {
39
+ export type EdgeObject = {
40
40
  source: (() => EdgeId) | EdgeId;
41
41
  target: (() => EdgeId) | EdgeId;
42
42
  navigationRules: NavigationList;
43
43
  };
44
- type NavObject = {
44
+ export type NavObject = {
45
45
  direction: Direction;
46
46
  key?: string;
47
47
  };
48
- type RenderObject = {
48
+ export type RenderObject = {
49
49
  cssClass?: DynamicString;
50
50
  dimensions?: Dimensions;
51
51
  semantics?: Semantics;
@@ -53,60 +53,60 @@ type RenderObject = {
53
53
  existingElement?: ExistingElement;
54
54
  showText?: boolean;
55
55
  };
56
- type RootObject = {
56
+ export type RootObject = {
57
57
  id: string;
58
58
  cssClass?: string;
59
59
  description?: string;
60
60
  width?: string | number;
61
61
  height?: string | number;
62
62
  };
63
- type EntryObject = {
63
+ export type EntryObject = {
64
64
  include: boolean;
65
65
  callbacks?: EntryCallbacks;
66
66
  };
67
- type ExitObject = {
67
+ export type ExitObject = {
68
68
  include: boolean;
69
69
  callbacks?: ExitCallbacks;
70
70
  };
71
- type SemanticsObject = {
71
+ export type SemanticsObject = {
72
72
  label?: DynamicString;
73
73
  elementType?: DynamicString;
74
74
  role?: DynamicString;
75
75
  attributes?: Attributes;
76
76
  };
77
- type DimensionsObject = {
77
+ export type DimensionsObject = {
78
78
  x?: DynamicNumber;
79
79
  y?: DynamicNumber;
80
80
  width?: DynamicNumber;
81
81
  height?: DynamicNumber;
82
82
  path?: DynamicString;
83
83
  };
84
- type DescriptionOptions = {
84
+ export type DescriptionOptions = {
85
85
  omitKeyNames?: boolean;
86
86
  semanticLabel?: string;
87
87
  };
88
- type ExistingElement = {
88
+ export type ExistingElement = {
89
89
  useForDimensions: boolean;
90
90
  dimensions?: Dimensions;
91
91
  };
92
- type EntryCallbacks = {
92
+ export type EntryCallbacks = {
93
93
  focus?: Function;
94
94
  click?: Function;
95
95
  };
96
- type ExitCallbacks = {
96
+ export type ExitCallbacks = {
97
97
  focus?: Function;
98
98
  blur?: Function;
99
99
  };
100
- type DatumObject = {
100
+ export type DatumObject = {
101
101
  [key: string | number]: any;
102
102
  };
103
- type AttributesObject = {
103
+ export type AttributesObject = {
104
104
  [key: string]: string;
105
105
  };
106
- type DynamicNumber = ((RenderObject?: any, DatumObject?: any) => number) | number;
107
- type DynamicString = ((RenderObject?: any, DatumObject?: any) => string) | string;
108
- type NodeId = string;
109
- type EdgeId = string;
110
- type RenderId = string;
111
- type NavId = string;
112
- type Direction = "target" | "source";
106
+ export type DynamicNumber = ((RenderObject?: any, DatumObject?: any) => number) | number;
107
+ export type DynamicString = ((RenderObject?: any, DatumObject?: any) => string) | string;
108
+ export type NodeId = string;
109
+ export type EdgeId = string;
110
+ export type RenderId = string;
111
+ export type NavId = string;
112
+ export type Direction = "target" | "source";
@@ -1,11 +1,11 @@
1
1
  declare const _default: {
2
- structure: (options: StructureOptions) => {
2
+ structure: (options: import("./data-navigator").StructureOptions) => {
3
3
  nodes: {};
4
4
  edges: {};
5
5
  elementData: {};
6
- navigationRules: NavigationRules;
6
+ navigationRules: import("./data-navigator").NavigationRules;
7
7
  };
8
- input: (options: InputOptions) => any;
9
- rendering: (options: RenderingOptions) => any;
8
+ input: (options: import("./data-navigator").InputOptions) => any;
9
+ rendering: (options: import("./data-navigator").RenderingOptions) => any;
10
10
  };
11
11
  export default _default;
@@ -1,2 +1,3 @@
1
+ import type { InputOptions } from './data-navigator';
1
2
  declare const _default: (options: InputOptions) => any;
2
3
  export default _default;
@@ -1,2 +1,3 @@
1
+ import type { RenderingOptions } from './data-navigator';
1
2
  declare const _default: (options: RenderingOptions) => any;
2
3
  export default _default;
@@ -1,14 +1,15 @@
1
+ import { StructureOptions } from './data-navigator';
1
2
  declare const _default: (options: StructureOptions) => {
2
3
  nodes: {};
3
4
  edges: {};
4
5
  elementData: {};
5
- navigationRules: NavigationRules;
6
+ navigationRules: import("./data-navigator").NavigationRules;
6
7
  };
7
8
  export default _default;
8
9
  export declare const buildNodeStructureFromVegaLite: (options: any) => {
9
10
  nodes: {};
10
11
  edges: {};
11
12
  elementData: {};
12
- navigationRules: NavigationRules;
13
+ navigationRules: import("./data-navigator").NavigationRules;
13
14
  };
14
15
  export declare const buildNodeStructure: (options: any) => {};
@@ -1 +1,2 @@
1
+ import { DatumObject, DescriptionOptions } from "./data-navigator";
1
2
  export declare const describeNode: (d: DatumObject, descriptionOptions?: DescriptionOptions) => string;
@@ -1 +1 @@
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};
1
+ import{a as L}from"./chunk-CCACYVYB.mjs";import{c as C}from"./chunk-GP5LYFFJ.mjs";var O=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={},c={},y=0,E=t.groupInclusionCriteria?t.groupInclusionCriteria:()=>!0,$=t.itemInclusionCriteria?t.itemInclusionCriteria:()=>!0,S=t.datumInclusionCriteria?t.datumInclusionCriteria:()=>!0,p=t.vegaLiteView._renderer._origin,b=t.vegaLiteView._scenegraph.root.items[0].mark.items[0],m=(e,i)=>{if(e["data-navigator-id"])return e["data-navigator-id"];let o=`dn-node-${i}-${y}`;return y++,e["data-navigator-id"]=o,o},k=e=>{let i=r[e],o=i.index,g=i.level,l=i.parent,n=[],d=l.items[o-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[o+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[o].items){let a=(l.items[o].items[0].mark.items[0].items||l.items[o].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},I=(e,i,o,g,l)=>{let n=m(e,i),d="render-"+n,f=o||[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,c[d]={},c[d].renderId=d,c[d].dimensions={},c[d].dimensions.x=e.bounds.x1+f[0],c[d].dimensions.y=e.bounds.y1+f[1],c[d].dimensions.width=e.bounds.x2-e.bounds.x1,c[d].dimensions.height=e.bounds.y2-e.bounds.y1,c[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)}),c[d].semantics={},c[d].semantics.label=t.nodeDescriber?t.nodeDescriber(r[n].d,e,i):L(r[n].d)},h=0;return b.items.forEach(e=>{if(E(e,h,t.vegaLiteSpec)){I(e,"group",p,h,b);let i=0,o=e.items[0].mark.items[0].items?e.items[0].mark.items[0]:e;o.items.forEach(g=>{$(g,i,e,t.vegaLiteSpec)&&I(g,"item",p,i,o),i++})}h++}),Object.keys(r).forEach(e=>{r[e].edges=k(e)}),{nodes:r,edges:u,elementData:c,navigationRules:R}},j=t=>({});export{j as buildNodeStructure,w as buildNodeStructureFromVegaLite,O as default};
@@ -1 +1 @@
1
- import{a}from"./chunk-KNRZ7RNY.mjs";export{a as describeNode};
1
+ import{a}from"./chunk-CCACYVYB.mjs";export{a as describeNode};
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "data-navigator",
3
3
  "author": "Frank Elavsky",
4
- "version": "1.2.2",
4
+ "version": "1.2.4",
5
5
  "main": "./dist/index.jsm",
6
6
  "module": "./dist/index",
7
- "types": "./dist/data-navigator.d.ts",
7
+ "types": "./dist/src/index.d.ts",
8
8
  "files": [
9
9
  "dist/**/*"
10
10
  ],
11
11
  "exports": {
12
12
  ".": {
13
13
  "import": {
14
- "types": "./dist/data-navigator.d.ts",
14
+ "types": "./dist/src/index.d.ts",
15
15
  "default": "./dist/index.js"
16
16
  },
17
17
  "require": {
18
- "types": "./dist/data-navigator.d.ts",
18
+ "types": "./dist/src/index.d.ts",
19
19
  "default": "./dist/index.mjs"
20
20
  }
21
21
  }