data-navigator 3.2.0 → 3.2.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/dist/index.cjs CHANGED
@@ -1870,11 +1870,12 @@ var rendering_default = (options) => {
1870
1870
  parentSemantics: __spreadValues({}, NodeElementDefaults.parentSemantics),
1871
1871
  existingElement: __spreadValues({}, NodeElementDefaults.existingElement)
1872
1872
  };
1873
+ const mergeDefault = (base, o) => typeof o === "function" ? o : __spreadValues(__spreadValues({}, base), o);
1873
1874
  if (options.defaults) {
1874
1875
  defaults.cssClass = options.defaults.cssClass || defaults.cssClass;
1875
- defaults.spatialProperties = options.defaults.spatialProperties ? __spreadValues(__spreadValues({}, defaults.spatialProperties), options.defaults.spatialProperties) : defaults.spatialProperties;
1876
- defaults.semantics = options.defaults.semantics ? __spreadValues(__spreadValues({}, defaults.semantics), options.defaults.semantics) : defaults.semantics;
1877
- defaults.parentSemantics = options.defaults.parentSemantics ? __spreadValues(__spreadValues({}, defaults.parentSemantics), options.defaults.parentSemantics) : defaults.parentSemantics;
1876
+ defaults.spatialProperties = options.defaults.spatialProperties ? mergeDefault(defaults.spatialProperties, options.defaults.spatialProperties) : defaults.spatialProperties;
1877
+ defaults.semantics = options.defaults.semantics ? mergeDefault(defaults.semantics, options.defaults.semantics) : defaults.semantics;
1878
+ defaults.parentSemantics = options.defaults.parentSemantics ? mergeDefault(defaults.parentSemantics, options.defaults.parentSemantics) : defaults.parentSemantics;
1878
1879
  defaults.existingElement = options.defaults.existingElement ? __spreadValues(__spreadValues({}, defaults.existingElement), options.defaults.existingElement) : defaults.existingElement;
1879
1880
  }
1880
1881
  renderer.initialize = () => {
@@ -1968,12 +1969,16 @@ var rendering_default = (options) => {
1968
1969
  }
1969
1970
  let useExisting = false;
1970
1971
  let existingSpatialProperties = {};
1971
- const resolveProp = (prop, subprop, checkExisting) => {
1972
+ const resolve = (v) => {
1972
1973
  var _a;
1973
- const p1 = d[prop] || defaults[prop];
1974
+ return typeof v === "function" ? v(d, (_a = nodeData.datum) != null ? _a : nodeData.data) : v;
1975
+ };
1976
+ const resolveProp = (prop, subprop, checkExisting) => {
1977
+ var _a, _b, _c;
1978
+ const p1 = resolve(d[prop] || defaults[prop]);
1974
1979
  const s1 = !(checkExisting && useExisting) ? p1 == null ? void 0 : p1[subprop] : existingSpatialProperties[subprop];
1975
- const s2 = (_a = defaults[prop]) == null ? void 0 : _a[subprop];
1976
- return typeof p1 === "function" ? p1(d, nodeData.datum) : typeof s1 === "function" ? s1(d, nodeData.datum) : s1 || s2 || (!subprop ? p1 : void 0);
1980
+ const s2 = (_c = (_a = resolve(defaults[prop])) == null ? void 0 : _a[subprop]) != null ? _c : (_b = NodeElementDefaults[prop]) == null ? void 0 : _b[subprop];
1981
+ return resolve(s1) || resolve(s2) || (!subprop ? p1 : void 0);
1977
1982
  };
1978
1983
  useExisting = resolveProp("existingElement", "useForSpatialProperties");
1979
1984
  existingSpatialProperties = resolveProp("existingElement", "spatialProperties");
package/dist/index.js CHANGED
@@ -1836,11 +1836,12 @@ var rendering_default = (options) => {
1836
1836
  parentSemantics: __spreadValues({}, NodeElementDefaults.parentSemantics),
1837
1837
  existingElement: __spreadValues({}, NodeElementDefaults.existingElement)
1838
1838
  };
1839
+ const mergeDefault = (base, o) => typeof o === "function" ? o : __spreadValues(__spreadValues({}, base), o);
1839
1840
  if (options.defaults) {
1840
1841
  defaults.cssClass = options.defaults.cssClass || defaults.cssClass;
1841
- defaults.spatialProperties = options.defaults.spatialProperties ? __spreadValues(__spreadValues({}, defaults.spatialProperties), options.defaults.spatialProperties) : defaults.spatialProperties;
1842
- defaults.semantics = options.defaults.semantics ? __spreadValues(__spreadValues({}, defaults.semantics), options.defaults.semantics) : defaults.semantics;
1843
- defaults.parentSemantics = options.defaults.parentSemantics ? __spreadValues(__spreadValues({}, defaults.parentSemantics), options.defaults.parentSemantics) : defaults.parentSemantics;
1842
+ defaults.spatialProperties = options.defaults.spatialProperties ? mergeDefault(defaults.spatialProperties, options.defaults.spatialProperties) : defaults.spatialProperties;
1843
+ defaults.semantics = options.defaults.semantics ? mergeDefault(defaults.semantics, options.defaults.semantics) : defaults.semantics;
1844
+ defaults.parentSemantics = options.defaults.parentSemantics ? mergeDefault(defaults.parentSemantics, options.defaults.parentSemantics) : defaults.parentSemantics;
1844
1845
  defaults.existingElement = options.defaults.existingElement ? __spreadValues(__spreadValues({}, defaults.existingElement), options.defaults.existingElement) : defaults.existingElement;
1845
1846
  }
1846
1847
  renderer.initialize = () => {
@@ -1934,12 +1935,16 @@ var rendering_default = (options) => {
1934
1935
  }
1935
1936
  let useExisting = false;
1936
1937
  let existingSpatialProperties = {};
1937
- const resolveProp = (prop, subprop, checkExisting) => {
1938
+ const resolve = (v) => {
1938
1939
  var _a;
1939
- const p1 = d[prop] || defaults[prop];
1940
+ return typeof v === "function" ? v(d, (_a = nodeData.datum) != null ? _a : nodeData.data) : v;
1941
+ };
1942
+ const resolveProp = (prop, subprop, checkExisting) => {
1943
+ var _a, _b, _c;
1944
+ const p1 = resolve(d[prop] || defaults[prop]);
1940
1945
  const s1 = !(checkExisting && useExisting) ? p1 == null ? void 0 : p1[subprop] : existingSpatialProperties[subprop];
1941
- const s2 = (_a = defaults[prop]) == null ? void 0 : _a[subprop];
1942
- return typeof p1 === "function" ? p1(d, nodeData.datum) : typeof s1 === "function" ? s1(d, nodeData.datum) : s1 || s2 || (!subprop ? p1 : void 0);
1946
+ const s2 = (_c = (_a = resolve(defaults[prop])) == null ? void 0 : _a[subprop]) != null ? _c : (_b = NodeElementDefaults[prop]) == null ? void 0 : _b[subprop];
1947
+ return resolve(s1) || resolve(s2) || (!subprop ? p1 : void 0);
1943
1948
  };
1944
1949
  useExisting = resolveProp("existingElement", "useForSpatialProperties");
1945
1950
  existingSpatialProperties = resolveProp("existingElement", "spatialProperties");
@@ -1 +1 @@
1
- var T=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames,H=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var _=(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={}))W.call(r,n)&&_(e,n,r[n]);if(H)for(var n of H(r))X.call(r,n)&&_(e,n,r[n]);return e};var ee=(e,r)=>{for(var n in r)T(e,n,{get:r[n],enumerable:!0})},te=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of q(r))!W.call(e,l)&&l!==n&&T(e,l,{get:()=>r[l],enumerable:!(t=Y(r,l))||t.enumerable});return e};var re=e=>te(T({},"__esModule",{value:!0}),e);var z=(e,r,n)=>{if(!r.has(e))throw TypeError("Cannot "+n)};var f=(e,r,n)=>(z(e,r,"read from private field"),n?n.call(e):r.get(e)),B=(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)},N=(e,r,n,t)=>(z(e,r,"write to private field"),t?t.call(e,n):r.set(e,n),n);var R=(e,r,n)=>(z(e,r,"access private method"),n);var se={};ee(se,{default:()=>ie});module.exports=re(se);var P={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}},Z={ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Enter:"Enter",Backspace:"Backspace",Escape:"Esc",Space:"Space",Tab:"Tab",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Slash:"/",Comma:",",Period:".",Semicolon:";",Quote:"'",Minus:"-",Equal:"="},J={"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"}},Q=[{label:"Command",id:"description"},{label:"Key",id:"label"}];var S,k,v,y,x,D,j=class extends HTMLElement{constructor(){super(...arguments);B(this,x);B(this,S,[]);B(this,k,Q);B(this,v,"label");B(this,y,!1)}static get observedAttributes(){return["title"]}set commands(n){N(this,S,n),f(this,y)&&R(this,x,D).call(this)}get commands(){return f(this,S)}set columns(n){N(this,k,n),f(this,y)&&R(this,x,D).call(this)}get columns(){return f(this,k)}set kbdColumn(n){N(this,v,n),f(this,y)&&R(this,x,D).call(this)}get kbdColumn(){return f(this,v)}attributeChangedCallback(){f(this,y)&&R(this,x,D).call(this)}connectedCallback(){N(this,y,!0),R(this,x,D).call(this)}disconnectedCallback(){N(this,y,!1)}};S=new WeakMap,k=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakSet,D=function(){this.replaceChildren();let n=[];for(let s of f(this,k)){let d=document.createElement("th");d.classList.add("dn-commands-table-th"),d.textContent=s.label,n.push(d)}let t=document.createElement("tr");t.classList.add("dn-commands-table-thead-tr");for(let s of n)t.appendChild(s);let l=document.createElement("thead");l.classList.add("dn-commands-table-thead"),l.appendChild(t);let o=document.createElement("tbody");o.classList.add("dn-commands-table-tbody");for(let s of f(this,S)){let d=[];for(let i of f(this,k)){let A=s[i.id],w=document.createElement("td");if(w.classList.add("dn-commands-table-td"),f(this,v)!==null&&i.id===f(this,v)&&A){let E=document.createElement("kbd");E.classList.add("dn-commands-table-td-kbd"),E.textContent=A,w.append(E)}else w.textContent=A;d.push(w)}let m=document.createElement("tr");m.classList.add("dn-commands-table-tbody-tr");for(let i of d)m.appendChild(i);o.appendChild(m)}let a=document.createElement("table");a.classList.add("dn-commands-table");let c=this.getAttribute("title");if(c){let s=document.createElement("caption");s.classList.add("dn-commands-table-caption"),s.textContent=c,a.appendChild(s)}else a.setAttribute("aria-label","Commands table");a.appendChild(l),a.appendChild(o),this.appendChild(a)};var ne=e=>e?Z[e]||e.replace(/^Key/,"").replace(/^Digit/,""):"",ae=e=>{let r=e.replace(/[-_]+/g," ").trim();return r.charAt(0).toUpperCase()+r.slice(1)};function G(e,r){return e?Object.keys(e).map(n=>{let t=e[n],l=J[n];return{label:t!=null&&t.key?ne(t.key):(l==null?void 0:l.label)||"",description:(r==null?void 0:r[n])||(l==null?void 0:l.description)||ae(n),command:n}}):[]}var ie=e=>{let r=a=>{t.wrapper.setAttribute("aria-activedescendant",a.srcElement.id)},n=()=>{t.wrapper.setAttribute("aria-activedescendant","")},t={},l=!1,o={cssClass:P.cssClass,spatialProperties:p({},P.spatialProperties),semantics:p({},P.semantics),parentSemantics:p({},P.parentSemantics),existingElement:p({},P.existingElement)};return e.defaults&&(o.cssClass=e.defaults.cssClass||o.cssClass,o.spatialProperties=e.defaults.spatialProperties?p(p({},o.spatialProperties),e.defaults.spatialProperties):o.spatialProperties,o.semantics=e.defaults.semantics?p(p({},o.semantics),e.defaults.semantics):o.semantics,o.parentSemantics=e.defaults.parentSemantics?p(p({},o.parentSemantics),e.defaults.parentSemantics):o.parentSemantics,o.existingElement=e.defaults.existingElement?p(p({},o.existingElement),e.defaults.existingElement):o.existingElement),t.initialize=()=>{var a,c;if(l){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),(c=e.exitElement)!=null&&c.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 d,m;t.exitElement.style.display="block",t.clearStructure(),(m=(d=e.exitElement)==null?void 0:d.callbacks)!=null&&m.focus&&e.exitElement.callbacks.focus(s)}),t.exitElement.addEventListener("blur",s=>{var d,m;t.exitElement.style.display="none",(m=(d=e.exitElement)==null?void 0:d.callbacks)!=null&&m.blur&&e.exitElement.callbacks.blur(s)}),t.root.appendChild(t.exitElement)),l=!0,t.root},t.render=a=>{let c=a.renderId+"",s=e.elementData[c];if(!s){console.warn(`Render data not found with renderId: ${c}. Failed to render.`);return}if(!l){console.error("render() was called before initialize(), renderer must be initialized first.");return}let d=!1,m={},i=(b,C,h)=>{var $;let g=s[b]||o[b],U=h&&d?m[C]:g==null?void 0:g[C],V=($=o[b])==null?void 0:$[C];return typeof g=="function"?g(s,a.datum):typeof U=="function"?U(s,a.datum):U||V||(C?void 0:g)};d=i("existingElement","useForSpatialProperties"),m=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),K=parseFloat(i("spatialProperties","y",!0)||0),u=document.createElement(i("parentSemantics","elementType")),I=i("parentSemantics","attributes");typeof I=="object"&&Object.keys(I).forEach(b=>{u.setAttribute(b,I[b])}),u.setAttribute("role",i("parentSemantics","role")),u.id=c,u.classList.add("dn-node"),u.classList.add(i("cssClass")),u.style.width=A+"px",u.style.height=w+"px",u.style.left=E+"px",u.style.top=K+"px",u.setAttribute("tabindex","0"),u.addEventListener("focus",r),u.addEventListener("blur",n);let L=document.createElement(i("semantics","elementType")),F=i("semantics","attributes");typeof F=="object"&&Object.keys(F).forEach(b=>{L.setAttribute(b,F[b])}),L.setAttribute("role",i("semantics","role")),L.classList.add("dn-node-text");let O=i("semantics","label");s.showText&&(L.innerText=O),O||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),L.setAttribute("aria-label",O),u.appendChild(L);let M=i("spatialProperties","path");if(M){let b=A+E+10,C=w+K+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=-K+"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),u.appendChild(h)}return t.wrapper.appendChild(u),u},t.remove=a=>{let c=document.getElementById(a);t.wrapper.getAttribute("aria-activedescendant")===a&&t.wrapper.setAttribute("aria-activedescendant",""),c&&(c.removeEventListener("focus",r),c.removeEventListener("blur",n),c.remove())},t.clearStructure=()=>{[...t.wrapper.children].forEach(a=>{t.entryButton&&t.entryButton===a||t.remove(a.id)})},t.initializeCommands=a=>{let c=document.getElementById(a==null?void 0:a.rootId);if(!c){console.error("Commands root element not found in document.");return}let s=a.commands,d=G(a.navigationRules,a.descriptions),m=s?typeof s=="function"?s(d):s:d;customElements.get("dn-commands-table")||customElements.define("dn-commands-table",j);let i=document.createElement("dn-commands-table");return a!=null&&a.title&&i.setAttribute("title",a.title),i.commands=m,a.columns&&(i.columns=a.columns),c.appendChild(i),i},t.getGenericCommandsFromNavRules=G,t.CommandsTable=j,t};
1
+ var T=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames,Z=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var J=(e,r,n)=>r in e?T(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,x=(e,r)=>{for(var n in r||(r={}))Q.call(r,n)&&J(e,n,r[n]);if(Z)for(var n of Z(r))ne.call(r,n)&&J(e,n,r[n]);return e};var ae=(e,r)=>{for(var n in r)T(e,n,{get:r[n],enumerable:!0})},ie=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of re(r))!Q.call(e,s)&&s!==n&&T(e,s,{get:()=>r[s],enumerable:!(t=te(r,s))||t.enumerable});return e};var se=e=>ie(T({},"__esModule",{value:!0}),e);var z=(e,r,n)=>{if(!r.has(e))throw TypeError("Cannot "+n)};var b=(e,r,n)=>(z(e,r,"read from private field"),n?n.call(e):r.get(e)),N=(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)},R=(e,r,n,t)=>(z(e,r,"write to private field"),t?t.call(e,n):r.set(e,n),n);var P=(e,r,n)=>(z(e,r,"access private method"),n);var ce={};ae(ce,{default:()=>de});module.exports=se(ce);var k={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}},V={ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Enter:"Enter",Backspace:"Backspace",Escape:"Esc",Space:"Space",Tab:"Tab",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Slash:"/",Comma:",",Period:".",Semicolon:";",Quote:"'",Minus:"-",Equal:"="},Y={"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"}},q=[{label:"Command",id:"description"},{label:"Key",id:"label"}];var S,v,A,w,C,D,j=class extends HTMLElement{constructor(){super(...arguments);N(this,C);N(this,S,[]);N(this,v,q);N(this,A,"label");N(this,w,!1)}static get observedAttributes(){return["title"]}set commands(n){R(this,S,n),b(this,w)&&P(this,C,D).call(this)}get commands(){return b(this,S)}set columns(n){R(this,v,n),b(this,w)&&P(this,C,D).call(this)}get columns(){return b(this,v)}set kbdColumn(n){R(this,A,n),b(this,w)&&P(this,C,D).call(this)}get kbdColumn(){return b(this,A)}attributeChangedCallback(){b(this,w)&&P(this,C,D).call(this)}connectedCallback(){R(this,w,!0),P(this,C,D).call(this)}disconnectedCallback(){R(this,w,!1)}};S=new WeakMap,v=new WeakMap,A=new WeakMap,w=new WeakMap,C=new WeakSet,D=function(){this.replaceChildren();let n=[];for(let i of b(this,v)){let o=document.createElement("th");o.classList.add("dn-commands-table-th"),o.textContent=i.label,n.push(o)}let t=document.createElement("tr");t.classList.add("dn-commands-table-thead-tr");for(let i of n)t.appendChild(i);let s=document.createElement("thead");s.classList.add("dn-commands-table-thead"),s.appendChild(t);let l=document.createElement("tbody");l.classList.add("dn-commands-table-tbody");for(let i of b(this,S)){let o=[];for(let p of b(this,v)){let f=i[p.id],d=document.createElement("td");if(d.classList.add("dn-commands-table-td"),b(this,A)!==null&&p.id===b(this,A)&&f){let L=document.createElement("kbd");L.classList.add("dn-commands-table-td-kbd"),L.textContent=f,d.append(L)}else d.textContent=f;o.push(d)}let m=document.createElement("tr");m.classList.add("dn-commands-table-tbody-tr");for(let p of o)m.appendChild(p);l.appendChild(m)}let y=document.createElement("table");y.classList.add("dn-commands-table");let a=this.getAttribute("title");if(a){let i=document.createElement("caption");i.classList.add("dn-commands-table-caption"),i.textContent=a,y.appendChild(i)}else y.setAttribute("aria-label","Commands table");y.appendChild(s),y.appendChild(l),this.appendChild(y)};var le=e=>e?V[e]||e.replace(/^Key/,"").replace(/^Digit/,""):"",oe=e=>{let r=e.replace(/[-_]+/g," ").trim();return r.charAt(0).toUpperCase()+r.slice(1)};function G(e,r){return e?Object.keys(e).map(n=>{let t=e[n],s=Y[n];return{label:t!=null&&t.key?le(t.key):(s==null?void 0:s.label)||"",description:(r==null?void 0:r[n])||(s==null?void 0:s.description)||oe(n),command:n}}):[]}var de=e=>{let r=a=>{t.wrapper.setAttribute("aria-activedescendant",a.srcElement.id)},n=()=>{t.wrapper.setAttribute("aria-activedescendant","")},t={},s=!1,l={cssClass:k.cssClass,spatialProperties:x({},k.spatialProperties),semantics:x({},k.semantics),parentSemantics:x({},k.parentSemantics),existingElement:x({},k.existingElement)},y=(a,i)=>typeof i=="function"?i:x(x({},a),i);return e.defaults&&(l.cssClass=e.defaults.cssClass||l.cssClass,l.spatialProperties=e.defaults.spatialProperties?y(l.spatialProperties,e.defaults.spatialProperties):l.spatialProperties,l.semantics=e.defaults.semantics?y(l.semantics,e.defaults.semantics):l.semantics,l.parentSemantics=e.defaults.parentSemantics?y(l.parentSemantics,e.defaults.parentSemantics):l.parentSemantics,l.existingElement=e.defaults.existingElement?x(x({},l.existingElement),e.defaults.existingElement):l.existingElement),t.initialize=()=>{var a,i;if(s){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),(i=e.exitElement)!=null&&i.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",o=>{var m,p;t.exitElement.style.display="block",t.clearStructure(),(p=(m=e.exitElement)==null?void 0:m.callbacks)!=null&&p.focus&&e.exitElement.callbacks.focus(o)}),t.exitElement.addEventListener("blur",o=>{var m,p;t.exitElement.style.display="none",(p=(m=e.exitElement)==null?void 0:m.callbacks)!=null&&p.blur&&e.exitElement.callbacks.blur(o)}),t.root.appendChild(t.exitElement)),s=!0,t.root},t.render=a=>{let i=a.renderId+"",o=e.elementData[i];if(!o){console.warn(`Render data not found with renderId: ${i}. Failed to render.`);return}if(!s){console.error("render() was called before initialize(), renderer must be initialized first.");return}let m=!1,p={},f=c=>{var g;return typeof c=="function"?c(o,(g=a.datum)!=null?g:a.data):c},d=(c,g,h)=>{var H,_,W;let E=f(o[c]||l[c]),X=h&&m?p[g]:E==null?void 0:E[g],ee=(W=(H=f(l[c]))==null?void 0:H[g])!=null?W:(_=k[c])==null?void 0:_[g];return f(X)||f(ee)||(g?void 0:E)};m=d("existingElement","useForSpatialProperties"),p=d("existingElement","spatialProperties");let L=parseFloat(d("spatialProperties","width",!0)||0),M=parseFloat(d("spatialProperties","height",!0)||0),K=parseFloat(d("spatialProperties","x",!0)||0),I=parseFloat(d("spatialProperties","y",!0)||0),u=document.createElement(d("parentSemantics","elementType")),F=d("parentSemantics","attributes");typeof F=="object"&&Object.keys(F).forEach(c=>{u.setAttribute(c,F[c])}),u.setAttribute("role",d("parentSemantics","role")),u.id=i,u.classList.add("dn-node"),u.classList.add(d("cssClass")),u.style.width=L+"px",u.style.height=M+"px",u.style.left=K+"px",u.style.top=I+"px",u.setAttribute("tabindex","0"),u.addEventListener("focus",r),u.addEventListener("blur",n);let B=document.createElement(d("semantics","elementType")),O=d("semantics","attributes");typeof O=="object"&&Object.keys(O).forEach(c=>{B.setAttribute(c,O[c])}),B.setAttribute("role",d("semantics","role")),B.classList.add("dn-node-text");let U=d("semantics","label");o.showText&&(B.innerText=U),U||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),B.setAttribute("aria-label",U),u.appendChild(B);let $=d("spatialProperties","path");if($){let c=L+K+10,g=M+I+10,h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("width",c+""),h.setAttribute("height",g+""),h.setAttribute("viewBox",`0 0 ${c} ${g}`),h.style.left=-K+"px",h.style.top=-I+"px",h.classList.add("dn-node-svg"),h.setAttribute("role","presentation"),h.setAttribute("focusable","false");let E=document.createElementNS("http://www.w3.org/2000/svg","path");E.setAttribute("d",$),E.classList.add("dn-node-path"),h.appendChild(E),u.appendChild(h)}return t.wrapper.appendChild(u),u},t.remove=a=>{let i=document.getElementById(a);t.wrapper.getAttribute("aria-activedescendant")===a&&t.wrapper.setAttribute("aria-activedescendant",""),i&&(i.removeEventListener("focus",r),i.removeEventListener("blur",n),i.remove())},t.clearStructure=()=>{[...t.wrapper.children].forEach(a=>{t.entryButton&&t.entryButton===a||t.remove(a.id)})},t.initializeCommands=a=>{let i=document.getElementById(a==null?void 0:a.rootId);if(!i){console.error("Commands root element not found in document.");return}let o=a.commands,m=G(a.navigationRules,a.descriptions),p=o?typeof o=="function"?o(m):o:m;customElements.get("dn-commands-table")||customElements.define("dn-commands-table",j);let f=document.createElement("dn-commands-table");return a!=null&&a.title&&f.setAttribute("title",a.title),f.commands=p,a.columns&&(f.columns=a.columns),i.appendChild(f),f},t.getGenericCommandsFromNavRules=G,t.CommandsTable=j,t};
package/dist/rendering.js CHANGED
@@ -1 +1 @@
1
- import{d as M}from"./chunk-ZTY2OAPD.js";import{a as o,c as m,d as k,e as B,f as P,q as S,t as V}from"./chunk-B5HGEXMZ.js";var I,w,v,h,E,T,j=class extends HTMLElement{constructor(){super(...arguments);k(this,E);k(this,I,[]);k(this,w,V);k(this,v,"label");k(this,h,!1)}static get observedAttributes(){return["title"]}set commands(b){B(this,I,b),m(this,h)&&P(this,E,T).call(this)}get commands(){return m(this,I)}set columns(b){B(this,w,b),m(this,h)&&P(this,E,T).call(this)}get columns(){return m(this,w)}set kbdColumn(b){B(this,v,b),m(this,h)&&P(this,E,T).call(this)}get kbdColumn(){return m(this,v)}attributeChangedCallback(){m(this,h)&&P(this,E,T).call(this)}connectedCallback(){B(this,h,!0),P(this,E,T).call(this)}disconnectedCallback(){B(this,h,!1)}};I=new WeakMap,w=new WeakMap,v=new WeakMap,h=new WeakMap,E=new WeakSet,T=function(){this.replaceChildren();let b=[];for(let a of m(this,w)){let i=document.createElement("th");i.classList.add("dn-commands-table-th"),i.textContent=a.label,b.push(i)}let e=document.createElement("tr");e.classList.add("dn-commands-table-thead-tr");for(let a of b)e.appendChild(a);let x=document.createElement("thead");x.classList.add("dn-commands-table-thead"),x.appendChild(e);let r=document.createElement("tbody");r.classList.add("dn-commands-table-tbody");for(let a of m(this,I)){let i=[];for(let s of m(this,w)){let A=a[s.id],C=document.createElement("td");if(C.classList.add("dn-commands-table-td"),m(this,v)!==null&&s.id===m(this,v)&&A){let y=document.createElement("kbd");y.classList.add("dn-commands-table-td-kbd"),y.textContent=A,C.append(y)}else C.textContent=A;i.push(C)}let c=document.createElement("tr");c.classList.add("dn-commands-table-tbody-tr");for(let s of i)c.appendChild(s);r.appendChild(c)}let n=document.createElement("table");n.classList.add("dn-commands-table");let l=this.getAttribute("title");if(l){let a=document.createElement("caption");a.classList.add("dn-commands-table-caption"),a.textContent=l,n.appendChild(a)}else n.setAttribute("aria-label","Commands table");n.appendChild(x),n.appendChild(r),this.appendChild(n)};var X=t=>{let R=n=>{e.wrapper.setAttribute("aria-activedescendant",n.srcElement.id)},b=()=>{e.wrapper.setAttribute("aria-activedescendant","")},e={},x=!1,r={cssClass:S.cssClass,spatialProperties:o({},S.spatialProperties),semantics:o({},S.semantics),parentSemantics:o({},S.parentSemantics),existingElement:o({},S.existingElement)};return t.defaults&&(r.cssClass=t.defaults.cssClass||r.cssClass,r.spatialProperties=t.defaults.spatialProperties?o(o({},r.spatialProperties),t.defaults.spatialProperties):r.spatialProperties,r.semantics=t.defaults.semantics?o(o({},r.semantics),t.defaults.semantics):r.semantics,r.parentSemantics=t.defaults.parentSemantics?o(o({},r.parentSemantics),t.defaults.parentSemantics):r.parentSemantics,r.existingElement=t.defaults.existingElement?o(o({},r.existingElement),t.defaults.existingElement):r.existingElement),e.initialize=()=>{var n,l;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.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),(n=t.commandsElement)!=null&&n.include&&e.initializeCommands(t.commandsElement),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),(l=t.exitElement)!=null&&l.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",a=>{var i,c;e.exitElement.style.display="block",e.clearStructure(),(c=(i=t.exitElement)==null?void 0:i.callbacks)!=null&&c.focus&&t.exitElement.callbacks.focus(a)}),e.exitElement.addEventListener("blur",a=>{var i,c;e.exitElement.style.display="none",(c=(i=t.exitElement)==null?void 0:i.callbacks)!=null&&c.blur&&t.exitElement.callbacks.blur(a)}),e.root.appendChild(e.exitElement)),x=!0,e.root},e.render=n=>{let l=n.renderId+"",a=t.elementData[l];if(!a){console.warn(`Render data not found with renderId: ${l}. Failed to render.`);return}if(!x){console.error("render() was called before initialize(), renderer must be initialized first.");return}let i=!1,c={},s=(u,g,f)=>{var G;let p=a[u]||r[u],H=f&&i?c[g]:p==null?void 0:p[g],W=(G=r[u])==null?void 0:G[g];return typeof p=="function"?p(a,n.datum):typeof H=="function"?H(a,n.datum):H||W||(g?void 0:p)};i=s("existingElement","useForSpatialProperties"),c=s("existingElement","spatialProperties");let A=parseFloat(s("spatialProperties","width",!0)||0),C=parseFloat(s("spatialProperties","height",!0)||0),y=parseFloat(s("spatialProperties","x",!0)||0),N=parseFloat(s("spatialProperties","y",!0)||0),d=document.createElement(s("parentSemantics","elementType")),D=s("parentSemantics","attributes");typeof D=="object"&&Object.keys(D).forEach(u=>{d.setAttribute(u,D[u])}),d.setAttribute("role",s("parentSemantics","role")),d.id=l,d.classList.add("dn-node"),d.classList.add(s("cssClass")),d.style.width=A+"px",d.style.height=C+"px",d.style.left=y+"px",d.style.top=N+"px",d.setAttribute("tabindex","0"),d.addEventListener("focus",R),d.addEventListener("blur",b);let L=document.createElement(s("semantics","elementType")),F=s("semantics","attributes");typeof F=="object"&&Object.keys(F).forEach(u=>{L.setAttribute(u,F[u])}),L.setAttribute("role",s("semantics","role")),L.classList.add("dn-node-text");let z=s("semantics","label");a.showText&&(L.innerText=z),z||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),L.setAttribute("aria-label",z),d.appendChild(L);let $=s("spatialProperties","path");if($){let u=A+y+10,g=C+N+10,f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("width",u+""),f.setAttribute("height",g+""),f.setAttribute("viewBox",`0 0 ${u} ${g}`),f.style.left=-y+"px",f.style.top=-N+"px",f.classList.add("dn-node-svg"),f.setAttribute("role","presentation"),f.setAttribute("focusable","false");let p=document.createElementNS("http://www.w3.org/2000/svg","path");p.setAttribute("d",$),p.classList.add("dn-node-path"),f.appendChild(p),d.appendChild(f)}return e.wrapper.appendChild(d),d},e.remove=n=>{let l=document.getElementById(n);e.wrapper.getAttribute("aria-activedescendant")===n&&e.wrapper.setAttribute("aria-activedescendant",""),l&&(l.removeEventListener("focus",R),l.removeEventListener("blur",b),l.remove())},e.clearStructure=()=>{[...e.wrapper.children].forEach(n=>{e.entryButton&&e.entryButton===n||e.remove(n.id)})},e.initializeCommands=n=>{let l=document.getElementById(n==null?void 0:n.rootId);if(!l){console.error("Commands root element not found in document.");return}let a=n.commands,i=M(n.navigationRules,n.descriptions),c=a?typeof a=="function"?a(i):a:i;customElements.get("dn-commands-table")||customElements.define("dn-commands-table",j);let s=document.createElement("dn-commands-table");return n!=null&&n.title&&s.setAttribute("title",n.title),s.commands=c,n.columns&&(s.columns=n.columns),l.appendChild(s),s},e.getGenericCommandsFromNavRules=M,e.CommandsTable=j,e};export{X as default};
1
+ import{d as M}from"./chunk-ZTY2OAPD.js";import{a as E,c as u,d as B,e as P,f as S,q as w,t as J}from"./chunk-B5HGEXMZ.js";var I,v,A,x,y,T,j=class extends HTMLElement{constructor(){super(...arguments);B(this,y);B(this,I,[]);B(this,v,J);B(this,A,"label");B(this,x,!1)}static get observedAttributes(){return["title"]}set commands(b){P(this,I,b),u(this,x)&&S(this,y,T).call(this)}get commands(){return u(this,I)}set columns(b){P(this,v,b),u(this,x)&&S(this,y,T).call(this)}get columns(){return u(this,v)}set kbdColumn(b){P(this,A,b),u(this,x)&&S(this,y,T).call(this)}get kbdColumn(){return u(this,A)}attributeChangedCallback(){u(this,x)&&S(this,y,T).call(this)}connectedCallback(){P(this,x,!0),S(this,y,T).call(this)}disconnectedCallback(){P(this,x,!1)}};I=new WeakMap,v=new WeakMap,A=new WeakMap,x=new WeakMap,y=new WeakSet,T=function(){this.replaceChildren();let b=[];for(let s of u(this,v)){let r=document.createElement("th");r.classList.add("dn-commands-table-th"),r.textContent=s.label,b.push(r)}let e=document.createElement("tr");e.classList.add("dn-commands-table-thead-tr");for(let s of b)e.appendChild(s);let g=document.createElement("thead");g.classList.add("dn-commands-table-thead"),g.appendChild(e);let a=document.createElement("tbody");a.classList.add("dn-commands-table-tbody");for(let s of u(this,I)){let r=[];for(let o of u(this,v)){let m=s[o.id],i=document.createElement("td");if(i.classList.add("dn-commands-table-td"),u(this,A)!==null&&o.id===u(this,A)&&m){let L=document.createElement("kbd");L.classList.add("dn-commands-table-td-kbd"),L.textContent=m,i.append(L)}else i.textContent=m;r.push(i)}let c=document.createElement("tr");c.classList.add("dn-commands-table-tbody-tr");for(let o of r)c.appendChild(o);a.appendChild(c)}let h=document.createElement("table");h.classList.add("dn-commands-table");let n=this.getAttribute("title");if(n){let s=document.createElement("caption");s.classList.add("dn-commands-table-caption"),s.textContent=n,h.appendChild(s)}else h.setAttribute("aria-label","Commands table");h.appendChild(g),h.appendChild(a),this.appendChild(h)};var ee=t=>{let R=n=>{e.wrapper.setAttribute("aria-activedescendant",n.srcElement.id)},b=()=>{e.wrapper.setAttribute("aria-activedescendant","")},e={},g=!1,a={cssClass:w.cssClass,spatialProperties:E({},w.spatialProperties),semantics:E({},w.semantics),parentSemantics:E({},w.parentSemantics),existingElement:E({},w.existingElement)},h=(n,s)=>typeof s=="function"?s:E(E({},n),s);return t.defaults&&(a.cssClass=t.defaults.cssClass||a.cssClass,a.spatialProperties=t.defaults.spatialProperties?h(a.spatialProperties,t.defaults.spatialProperties):a.spatialProperties,a.semantics=t.defaults.semantics?h(a.semantics,t.defaults.semantics):a.semantics,a.parentSemantics=t.defaults.parentSemantics?h(a.parentSemantics,t.defaults.parentSemantics):a.parentSemantics,a.existingElement=t.defaults.existingElement?E(E({},a.existingElement),t.defaults.existingElement):a.existingElement),e.initialize=()=>{var n,s;if(g){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),(n=t.commandsElement)!=null&&n.include&&e.initializeCommands(t.commandsElement),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),(s=t.exitElement)!=null&&s.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=>{var c,o;e.exitElement.style.display="block",e.clearStructure(),(o=(c=t.exitElement)==null?void 0:c.callbacks)!=null&&o.focus&&t.exitElement.callbacks.focus(r)}),e.exitElement.addEventListener("blur",r=>{var c,o;e.exitElement.style.display="none",(o=(c=t.exitElement)==null?void 0:c.callbacks)!=null&&o.blur&&t.exitElement.callbacks.blur(r)}),e.root.appendChild(e.exitElement)),g=!0,e.root},e.render=n=>{let s=n.renderId+"",r=t.elementData[s];if(!r){console.warn(`Render data not found with renderId: ${s}. Failed to render.`);return}if(!g){console.error("render() was called before initialize(), renderer must be initialized first.");return}let c=!1,o={},m=l=>{var p;return typeof l=="function"?l(r,(p=n.datum)!=null?p:n.data):l},i=(l,p,f)=>{var V,W,q;let C=m(r[l]||a[l]),K=f&&c?o[p]:C==null?void 0:C[p],O=(q=(V=m(a[l]))==null?void 0:V[p])!=null?q:(W=w[l])==null?void 0:W[p];return m(K)||m(O)||(p?void 0:C)};c=i("existingElement","useForSpatialProperties"),o=i("existingElement","spatialProperties");let L=parseFloat(i("spatialProperties","width",!0)||0),$=parseFloat(i("spatialProperties","height",!0)||0),D=parseFloat(i("spatialProperties","x",!0)||0),N=parseFloat(i("spatialProperties","y",!0)||0),d=document.createElement(i("parentSemantics","elementType")),F=i("parentSemantics","attributes");typeof F=="object"&&Object.keys(F).forEach(l=>{d.setAttribute(l,F[l])}),d.setAttribute("role",i("parentSemantics","role")),d.id=s,d.classList.add("dn-node"),d.classList.add(i("cssClass")),d.style.width=L+"px",d.style.height=$+"px",d.style.left=D+"px",d.style.top=N+"px",d.setAttribute("tabindex","0"),d.addEventListener("focus",R),d.addEventListener("blur",b);let k=document.createElement(i("semantics","elementType")),z=i("semantics","attributes");typeof z=="object"&&Object.keys(z).forEach(l=>{k.setAttribute(l,z[l])}),k.setAttribute("role",i("semantics","role")),k.classList.add("dn-node-text");let H=i("semantics","label");r.showText&&(k.innerText=H),H||console.error("Accessibility error: a label must be supplied to every rendered element using semantics.label."),k.setAttribute("aria-label",H),d.appendChild(k);let G=i("spatialProperties","path");if(G){let l=L+D+10,p=$+N+10,f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("width",l+""),f.setAttribute("height",p+""),f.setAttribute("viewBox",`0 0 ${l} ${p}`),f.style.left=-D+"px",f.style.top=-N+"px",f.classList.add("dn-node-svg"),f.setAttribute("role","presentation"),f.setAttribute("focusable","false");let C=document.createElementNS("http://www.w3.org/2000/svg","path");C.setAttribute("d",G),C.classList.add("dn-node-path"),f.appendChild(C),d.appendChild(f)}return e.wrapper.appendChild(d),d},e.remove=n=>{let s=document.getElementById(n);e.wrapper.getAttribute("aria-activedescendant")===n&&e.wrapper.setAttribute("aria-activedescendant",""),s&&(s.removeEventListener("focus",R),s.removeEventListener("blur",b),s.remove())},e.clearStructure=()=>{[...e.wrapper.children].forEach(n=>{e.entryButton&&e.entryButton===n||e.remove(n.id)})},e.initializeCommands=n=>{let s=document.getElementById(n==null?void 0:n.rootId);if(!s){console.error("Commands root element not found in document.");return}let r=n.commands,c=M(n.navigationRules,n.descriptions),o=r?typeof r=="function"?r(c):r:c;customElements.get("dn-commands-table")||customElements.define("dn-commands-table",j);let m=document.createElement("dn-commands-table");return n!=null&&n.title&&m.setAttribute("title",n.title),m.commands=o,n.columns&&(m.columns=n.columns),s.appendChild(m),m},e.getGenericCommandsFromNavRules=M,e.CommandsTable=j,e};export{ee as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "data-navigator",
3
3
  "author": "Frank Elavsky",
4
- "version": "3.2.0",
4
+ "version": "3.2.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",