wunderbaum 0.5.3 → 0.5.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.
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Wunderbaum - util
3
3
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
4
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
4
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
5
5
  */
6
6
  /** @module util */
7
7
  /** Readable names for `MouseEvent.button` */
@@ -765,7 +765,7 @@ var util = /*#__PURE__*/Object.freeze({
765
765
  /*!
766
766
  * Wunderbaum - types
767
767
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
768
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
768
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
769
769
  */
770
770
  /**
771
771
  * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
@@ -829,7 +829,7 @@ var NavModeEnum;
829
829
  /*!
830
830
  * Wunderbaum - wb_extension_base
831
831
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
832
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
832
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
833
833
  */
834
834
  class WunderbaumExtension {
835
835
  constructor(tree, id, defaults) {
@@ -1185,7 +1185,7 @@ function throttle(func, wait = 0, options = {}) {
1185
1185
  /*!
1186
1186
  * Wunderbaum - ext-filter
1187
1187
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1188
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1188
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1189
1189
  */
1190
1190
  const START_MARKER = "\uFFF7";
1191
1191
  const END_MARKER = "\uFFF8";
@@ -1485,7 +1485,7 @@ function _markFuzzyMatchedChars(text, matches, escapeTitles = true) {
1485
1485
  /*!
1486
1486
  * Wunderbaum - ext-keynav
1487
1487
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1488
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1488
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1489
1489
  */
1490
1490
  const QUICKSEARCH_DELAY = 500;
1491
1491
  class KeynavExtension extends WunderbaumExtension {
@@ -1831,7 +1831,7 @@ class KeynavExtension extends WunderbaumExtension {
1831
1831
  /*!
1832
1832
  * Wunderbaum - ext-logger
1833
1833
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1834
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1834
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1835
1835
  */
1836
1836
  class LoggerExtension extends WunderbaumExtension {
1837
1837
  constructor(tree) {
@@ -1873,7 +1873,7 @@ class LoggerExtension extends WunderbaumExtension {
1873
1873
  /*!
1874
1874
  * Wunderbaum - common
1875
1875
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1876
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1876
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1877
1877
  */
1878
1878
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
1879
1879
  /**
@@ -2139,7 +2139,7 @@ function inflateSourceData(source) {
2139
2139
  /*!
2140
2140
  * Wunderbaum - ext-dnd
2141
2141
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2142
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2142
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2143
2143
  */
2144
2144
  const nodeMimeType = "application/x-wunderbaum-node";
2145
2145
  class DndExtension extends WunderbaumExtension {
@@ -2511,7 +2511,7 @@ class DndExtension extends WunderbaumExtension {
2511
2511
  /*!
2512
2512
  * Wunderbaum - drag_observer
2513
2513
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2514
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2514
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2515
2515
  */
2516
2516
  /**
2517
2517
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2647,7 +2647,7 @@ class DragObserver {
2647
2647
  /*!
2648
2648
  * Wunderbaum - ext-grid
2649
2649
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2650
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2650
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2651
2651
  */
2652
2652
  class GridExtension extends WunderbaumExtension {
2653
2653
  constructor(tree) {
@@ -2684,7 +2684,7 @@ class GridExtension extends WunderbaumExtension {
2684
2684
  /*!
2685
2685
  * Wunderbaum - deferred
2686
2686
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2687
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2687
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2688
2688
  */
2689
2689
  /**
2690
2690
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -2737,7 +2737,7 @@ class Deferred {
2737
2737
  /*!
2738
2738
  * Wunderbaum - wunderbaum_node
2739
2739
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2740
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2740
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2741
2741
  */
2742
2742
  /** WunderbaumNode properties that can be passed with source data.
2743
2743
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -5062,7 +5062,7 @@ WunderbaumNode.sequence = 0;
5062
5062
  /*!
5063
5063
  * Wunderbaum - ext-edit
5064
5064
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
5065
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
5065
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
5066
5066
  */
5067
5067
  // const START_MARKER = "\uFFF7";
5068
5068
  class EditExtension extends WunderbaumExtension {
@@ -5358,8 +5358,8 @@ class EditExtension extends WunderbaumExtension {
5358
5358
  * https://github.com/mar10/wunderbaum
5359
5359
  *
5360
5360
  * Released under the MIT license.
5361
- * @version v0.5.3
5362
- * @date Sun, 15 Oct 2023 16:42:56 GMT
5361
+ * @version v0.5.4
5362
+ * @date Sun, 15 Oct 2023 16:43:28 GMT
5363
5363
  */
5364
5364
  // import "./wunderbaum.scss";
5365
5365
  class WbSystemRoot extends WunderbaumNode {
@@ -7491,7 +7491,7 @@ class Wunderbaum {
7491
7491
  }
7492
7492
  Wunderbaum.sequence = 0;
7493
7493
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
7494
- Wunderbaum.version = "v0.5.3"; // Set to semver by 'grunt release'
7494
+ Wunderbaum.version = "v0.5.4"; // Set to semver by 'grunt release'
7495
7495
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
7496
7496
  Wunderbaum.util = util;
7497
7497
 
@@ -1,18 +1,18 @@
1
1
  /*!
2
2
  * Wunderbaum - util
3
3
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
4
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
4
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
5
5
  */
6
6
  const MOUSE_BUTTONS={0:"",1:"left",2:"middle",3:"right",4:"back",5:"forward"},MAX_INT=9007199254740991,userInfo=_getUserInfo(),isMac=userInfo.isMac,REX_HTML=/[&<>"'/]/g,REX_TOOLTIP=/[<>"'/]/g,ENTITY_MAP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let Deferred$1=class{constructor(){this.thens=[],this.catches=[],this.status=""}resolve(e){if(this.status)throw new Error("already settled");this.status="resolved",this.resolvedValue=e,this.thens.forEach((t=>t(e))),this.thens=[]}reject(e){if(this.status)throw new Error("already settled");this.status="rejected",this.rejectedError=e,this.catches.forEach((t=>t(e))),this.catches=[]}then(e){"resolved"===status?e(this.resolvedValue):this.thens.unshift(e)}catch(e){"rejected"===this.status?e(this.rejectedError):this.catches.unshift(e)}promise(){return{then:this.then,catch:this.catch}}};function assert(e,t){if(!e)throw t=t||"Assertion failed.",new Error(t)}function _getUserInfo(){const e=navigator;return{isMac:/Mac/.test(e.platform)}}function documentReady(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}function documentReadyPromise(){return new Promise((e=>{documentReady(e)}))}function each(e,t){if(null==e)return e;const i=e.length;let s=0;if("number"==typeof i)for(;s<i&&!1!==t.call(e[s],s,e[s]);s++);else for(const i in e)if(!1===t.call(e[s],i,e[i]))break;return e}function error(e){throw new Error(e)}function escapeHtml(e){return(""+e).replace(REX_HTML,(function(e){return ENTITY_MAP[e]}))}function escapeRegex(e){return(""+e).replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function escapeTooltip(e){return(""+e).replace(REX_TOOLTIP,(function(e){return ENTITY_MAP[e]}))}function extractHtmlText(e){return e.indexOf(">")>=0&&error("Not implemented"),e}function getValueFromElem(e,t=!1){const i=e.tagName;let s=null;if("SPAN"===i&&e.classList.contains("wb-col")){const i=e,n=i.querySelector("input,select");if(n)return getValueFromElem(n,t);i.innerText=""+s}else if("INPUT"===i){const i=e;switch(i.type){case"button":case"reset":case"submit":case"image":break;case"checkbox":s=i.indeterminate?null:i.checked;break;case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":s=t?i.valueAsDate:i.value;break;case"number":case"range":s=i.valueAsNumber;break;case"radio":{const e=i.name,t=i.parentElement.querySelector(`input[name="${e}"]:checked`);s=t?t.value:void 0}break;default:s=i.value}}else if("SELECT"===i){s=e.value}return s}function setValueToElem(e,t){const i=e.tagName;if("SPAN"===i&&e.classList.contains("wb-col")){const i=e,s=i.querySelector("input,select");if(s)return setValueToElem(s,t);i.innerText=""+t}else if("INPUT"===i){const i=e,s=i.type;switch(s){case"checkbox":i.indeterminate=null===t,i.checked=!!t;break;case"date":case"month":case"time":case"week":case"datetime":case"datetime-local":i.valueAsDate=new Date(t);break;case"number":case"range":null==t?i.value=t:i.valueAsNumber=t;break;case"radio":error(`Not yet implemented: ${s}`);break;case"button":case"reset":case"submit":case"image":break;default:i.value=null!=t?t:""}}else if("SELECT"===i){const i=e;null==t?i.selectedIndex=-1:i.value=t}}function setElemDisplay(e,t){const i=elemFromSelector(e).style;t?"none"===i.display&&(i.display=""):""===i.display&&(i.display="none")}function elemFromHtml(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstElementChild}const _IGNORE_KEYS=new Set(["Alt","Control","Meta","Shift"]);function elemFromSelector(e){return e?"string"==typeof e?document.querySelector(e):e:null}function eventTargetFromSelector(e){return e?"string"==typeof e?document.querySelector(e):e:null}function eventToString(e){const t=e.key,i=e.type,s=[];return e.altKey&&s.push("Alt"),e.ctrlKey&&s.push("Control"),e.metaKey&&s.push("Meta"),e.shiftKey&&s.push("Shift"),"click"===i||"dblclick"===i?s.push(MOUSE_BUTTONS[e.button]+i):"wheel"===i?s.push(i):_IGNORE_KEYS.has(t)||s.push(t),s.join("+")}function extend(...e){for(let t=1;t<e.length;t++){const i=e[t];if(null!=i)for(const t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[0][t]=i[t])}return e[0]}function isArray(e){return Array.isArray(e)}function isEmptyObject(e){return 0===Object.keys(e).length&&e.constructor===Object}function isFunction(e){return"function"==typeof e}function isPlainObject(e){return"[object Object]"===Object.prototype.toString.call(e)}function noop(...e){}function onEvent(e,t,i,s){let n,r;e=eventTargetFromSelector(e),s?(n=i,r=s):(n="",r=i),t.split(" ").forEach((t=>{e.addEventListener(t,(function(e){if(!n)return r(e);if(e.target){let t=e.target;if(t.matches(n))return r(e);if(t=t.closest(n),t)return r(e)}}))}))}function overrideMethod(e,t,i,s){let n,r;const o=s||e,l=e[t],a=(...e)=>l.apply(o,e),d=e=>l.apply(o,e);e[t]=(...e)=>{try{return n=o._super,r=o._superApply,o._super=a,o._superApply=d,i.apply(o,e)}finally{o._super=n,o._superApply=r}}}function setTimeoutPromise(e,t){return new Promise(((i,s)=>{setTimeout((()=>{try{i(e.apply(this))}catch(e){s(e)}}),t)}))}async function sleep(e){return new Promise((t=>setTimeout(t,e)))}function toggleCheckbox(e,t,i){const s=elemFromSelector(e);if(assert("checkbox"===s.type),null!=i||(i=s.classList.contains("wb-tristate")||s.indeterminate),void 0===t){switch(s.indeterminate?null:s.checked){case!0:t=!1;break;case!1:t=!i||null;break;case null:t=!0}}s.indeterminate=null==t,s.checked=!!t}function getOption(e,t,i=void 0){let s;e&&t.indexOf(".")>=0&&([s,t]=t.split("."),e=e[s]);const n=e?e[t]:null;return null!=n?n:i}function toSet(e){if(e instanceof Set)return e;if("string"==typeof e){const t=new Set;for(const i of e.split(" "))t.add(i.trim());return t}if(Array.isArray(e))return new Set(e);throw new Error("Cannot convert to Set<string>: "+e)}function type(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()}function adaptiveThrottle(e,t){let i=0,s=null;const n=Object.assign({minDelay:16,defaultDelay:200,maxDelay:5e3,delayFactor:2},t),r=Math.max(16,+n.minDelay),o=+n.maxDelay,l=(...t)=>{if(i)s=t,i+=1;else{i=1;const a=t;s=null;const d=Date.now();try{e.apply(this,a)}catch(e){console.error(e)}const c=Date.now()-d,h=Math.min(Math.max(r,c*n.delayFactor),o),u=Math.max(r,h-c);setTimeout((()=>{i=0,null!=s&&l.apply(this,s)}),u)}};return l}var ChangeType,RenderFlag,NodeStatusType,NodeRegion,NavModeEnum,util=Object.freeze({__proto__:null,Deferred:Deferred$1,MAX_INT:MAX_INT,MOUSE_BUTTONS:MOUSE_BUTTONS,adaptiveThrottle:adaptiveThrottle,assert:assert,documentReady:documentReady,documentReadyPromise:documentReadyPromise,each:each,elemFromHtml:elemFromHtml,elemFromSelector:elemFromSelector,error:error,escapeHtml:escapeHtml,escapeRegex:escapeRegex,escapeTooltip:escapeTooltip,eventTargetFromSelector:eventTargetFromSelector,eventToString:eventToString,extend:extend,extractHtmlText:extractHtmlText,getOption:getOption,getValueFromElem:getValueFromElem,isArray:isArray,isEmptyObject:isEmptyObject,isFunction:isFunction,isMac:isMac,isPlainObject:isPlainObject,noop:noop,onEvent:onEvent,overrideMethod:overrideMethod,setElemDisplay:setElemDisplay,setTimeoutPromise:setTimeoutPromise,setValueToElem:setValueToElem,sleep:sleep,toSet:toSet,toggleCheckbox:toggleCheckbox,type:type});
7
7
  /*!
8
8
  * Wunderbaum - types
9
9
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
10
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
10
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
11
11
  */!function(e){e.any="any",e.data="data",e.colStructure="colStructure",e.resize="resize",e.row="row",e.structure="structure",e.status="status",e.scroll="scroll"}(ChangeType||(ChangeType={})),function(e){e.clearMarkup="clearMarkup",e.header="header",e.redraw="redraw",e.scroll="scroll"}(RenderFlag||(RenderFlag={})),function(e){e.ok="ok",e.loading="loading",e.error="error",e.noData="noData",e.paging="paging"}(NodeStatusType||(NodeStatusType={})),function(e){e.unknown="",e.checkbox="checkbox",e.column="column",e.expander="expander",e.icon="icon",e.prefix="prefix",e.title="title"}(NodeRegion||(NodeRegion={})),function(e){e.startRow="startRow",e.cell="cell",e.startCell="startCell",e.row="row"}(NavModeEnum||(NavModeEnum={}));
12
12
  /*!
13
13
  * Wunderbaum - wb_extension_base
14
14
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
15
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
15
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
16
16
  */
17
17
  class WunderbaumExtension{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id=t,this.treeOpts=e.options;const s=e.options;void 0===this.treeOpts[t]?s[t]=this.extensionOpts=extend({},i):(this.extensionOpts=extend({},i,s[t]),s[t]=this.extensionOpts),this.enabled=this.getPluginOption("enabled",!0)}init(){this.tree.element.classList.add("wb-ext-"+this.id)}getPluginOption(e,t){var i;return null!==(i=this.extensionOpts[e])&&void 0!==i?i:t}setPluginOption(e,t){this.extensionOpts[e]=t}setEnabled(e=!0){return this.setPluginOption("enabled",!!e)}onKeyEvent(e){}onRender(e){}}
18
18
  /*!
@@ -23,52 +23,52 @@ class WunderbaumExtension{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id
23
23
  /*!
24
24
  * Wunderbaum - ext-filter
25
25
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
26
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
26
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
27
27
  */const START_MARKER="￷",END_MARKER="￸",RE_START_MARKER=new RegExp(escapeRegex("￷"),"g"),RE_END_MARTKER=new RegExp(escapeRegex("￸"),"g");class FilterExtension extends WunderbaumExtension{constructor(e){super(e,"filter",{connectInput:null,autoApply:!0,autoExpand:!1,counter:!0,fuzzy:!1,hideExpandedCounter:!0,hideExpanders:!1,highlight:!0,leavesOnly:!1,mode:"dim",noData:!0}),this.lastFilterArgs=null}init(){super.init();const e=this.getPluginOption("connectInput");e&&(this.queryInput=elemFromSelector(e),onEvent(this.queryInput,"input",debounce((e=>{this.filterNodes(this.queryInput.value.trim(),{})}),700)))}setPluginOption(e,t){if(super.setPluginOption(e,t),"mode"===e)this.tree.filterMode="hide"===t?"hide":"dim",this.tree.updateFilter()}_applyFilterNoUpdate(e,t,i){return this.tree.runWithDeferredUpdate((()=>this._applyFilterImpl(e,t,i)))}_applyFilterImpl(e,t,i){let s,n,r=0;const o=Date.now(),l=this.tree,a=l.options,d=a.autoCollapse,c=extend({},a.filter,i),h="hide"===c.mode,u=!!c.leavesOnly&&!t;if("string"==typeof e){if(""===e)return l.logInfo("Passing an empty string as a filter is handled as clearFilter()."),void this.clearFilter();s=c.fuzzy?e.split("").map(escapeRegex).reduce((function(e,t){return e+"([^"+t+"]*)"+t}),""):escapeRegex(e);const t=new RegExp(s,"i"),i=new RegExp(escapeRegex(e),"gi");e=e=>{if(!e.title)return!1;const s=e.title,r=s.match(t);return r&&c.highlight&&(n=c.fuzzy?_markFuzzyMatchedChars(s,r,!0):s.replace(i,(function(e){return"￷"+e+"￸"})),e.titleWithHighlight=escapeHtml(n).replace(RE_START_MARKER,"<mark>").replace(RE_END_MARTKER,"</mark>")),!!r}}return l.filterMode=c.mode,this.lastFilterArgs=arguments,l.element.classList.toggle("wb-ext-filter-hide",!!h),l.element.classList.toggle("wb-ext-filter-dim",!h),l.element.classList.toggle("wb-ext-filter-hide-expanders",!!c.hideExpanders),l.root.subMatchCount=0,l.visit((e=>{delete e.match,delete e.titleWithHighlight,e.subMatchCount=0})),l.setStatus(NodeStatusType.ok),a.autoCollapse=!1,l.visit((i=>{if(u&&null!=i.children)return;let s=e(i);if("skip"===s)return i.visit((function(e){e.match=!1}),!0),"skip";let n=!1;(t||"branch"===s)&&i.parent.match&&(s=!0,n=!0),s&&(r++,i.match=!0,i.visitParents((e=>{e!==i&&(e.subMatchCount+=1),!c.autoExpand||n||e.expanded||(e.setExpanded(!0,{noAnimation:!0,noEvents:!0}),e._filterAutoExpanded=!0)}),!0))})),a.autoCollapse=d,0===r&&c.noData&&h&&l.root.setStatus(NodeStatusType.noData),l.logInfo(`Filter '${s}' found ${r} nodes in ${Date.now()-o} ms.`),r}filterNodes(e,t){return this._applyFilterNoUpdate(e,!1,t)}filterBranches(e,t){return this._applyFilterNoUpdate(e,!0,t)}updateFilter(){var e;const t=this.tree;t.filterMode&&this.lastFilterArgs&&(null===(e=t.options.filter)||void 0===e?void 0:e.autoApply)?this._applyFilterNoUpdate.apply(this,this.lastFilterArgs):t.logWarn("updateFilter(): no filter active.")}clearFilter(){const e=this.tree;e.enableUpdate(!1),e.setStatus(NodeStatusType.ok),delete e.root.match,delete e.root.subMatchCount,e.visit((e=>{delete e.match,delete e.subMatchCount,delete e.titleWithHighlight,e._filterAutoExpanded&&e.expanded&&e.setExpanded(!1,{noAnimation:!0,noEvents:!0}),delete e._filterAutoExpanded})),e.filterMode=null,this.lastFilterArgs=null,e.element.classList.remove("wb-ext-filter-dim","wb-ext-filter-hide"),e.enableUpdate(!0)}}function _markFuzzyMatchedChars(e,t,i=!0){const s=[];for(let e=1;e<t.length;e++){const i=t[e].length+(1===e?0:1)+(s[s.length-1]||0);s.push(i)}const n=e.split("");return i?s.forEach((function(e){n[e]="￷"+n[e]+"￸"})):s.forEach((function(e){n[e]="<mark>"+n[e]+"</mark>"})),n.join("")}
28
28
  /*!
29
29
  * Wunderbaum - ext-keynav
30
30
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
31
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
31
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
32
32
  */const QUICKSEARCH_DELAY=500;class KeynavExtension extends WunderbaumExtension{constructor(e){super(e,"keynav",{})}_getEmbeddedInputElem(e){var t;let i=null;if(e&&null!=e.type)i=e;else{const e=null===(t=this.tree.getActiveColElem())||void 0===t?void 0:t.querySelector("input,select");e&&(i=e)}return i}_isCurInputFocused(){var e;return!!(null===(e=this.tree.getActiveColElem())||void 0===e?void 0:e.querySelector("input:focus,select:focus"))}onKeyEvent(e){const t=e.event,i=this.tree,s=e.options,n=!t.ctrlKey||s.autoActivate,r=this._getEmbeddedInputElem(t.target),o=r&&this._isCurInputFocused(),l=s.navigationModeOption;let a,d=eventToString(t),c=e.node,h=!0;if(!i.isEnabled())return!1;if(!1===i._callEvent("keydown",e))return!1;if(!1===i._callMethod("edit._preprocessKeyEvent",e))return!1;if(!c){const e=i.getFocusNode()||i.getActiveNode(),t=i.getFirstChild();if(!e&&t&&"ArrowDown"===d)return t.logInfo("Keydown: activate first node."),void t.setActive();a=e||t,a&&(a.setFocus(),c=i.getFocusNode(),c.logInfo("Keydown: force focus on active node."))}const u=c.isColspan();if(i.isRowNav()){if(o){switch(d){case"Enter":r.blur(),i.setFocus();break;case"Escape":c._render(),i.setFocus()}return}if(s.quicksearch&&1===d.length&&/^\w$/.test(d)&&!r){const e=Date.now();e-i.lastQuicksearchTime>500&&(i.lastQuicksearchTerm=""),i.lastQuicksearchTime=e,i.lastQuicksearchTerm+=d;const s=i.findNextNode(i.lastQuicksearchTerm,i.getActiveNode());return s&&s.setActive(!0,{event:t}),void t.preventDefault()}switch(d){case"Enter":c.isActive()&&(c.isExpanded()?d="Subtract":c.isExpandable(!0)&&(d="Add"));break;case"ArrowLeft":c.expanded&&(d="Subtract");break;case"ArrowRight":if(!c.expanded&&c.isExpandable(!0))d="Add";else if(l===NavModeEnum.startCell||l===NavModeEnum.startRow)return t.preventDefault(),i.setCellNav(),!1}switch(d){case"+":case"Add":c.setExpanded(!0);break;case"-":case"Subtract":c.setExpanded(!1);break;case" ":c.getOption("checkbox")?c.toggleSelected():c.setActive(!0,{event:t});break;case"Enter":c.setActive(!0,{event:t});break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":c.navigate(d,{activate:n,event:t});break;default:h=!1}}else{const e=this._getEmbeddedInputElem(null),s=e?e.type||e.tagName:"",r=e&&this._isCurInputFocused(),o=e&&"checkbox"!==s;if(r){if("Escape"===d)return c._render(),c.logDebug("Reset focused input"),i.setFocus(),void i.setColumn(i.activeColIdx);if("Enter"!==d)return void c.logDebug(`Ignored ${d} inside focused input`)}else if(e&&1===d.length&&o)return e.focus(),e.value="",c.logDebug(`Focus imput: ${d}`),!1;switch("Tab"===d?(d="ArrowRight",h=!0):"Shift+Tab"===d&&(d=i.activeColIdx>0?"ArrowLeft":"",h=!0),d){case"+":case"Add":c.setExpanded(!0);break;case"-":case"Subtract":c.setExpanded(!1);break;case" ":0===i.activeColIdx&&c.getOption("checkbox")?(c.toggleSelected(),h=!0):e&&"checkbox"===s&&(e.click(),h=!0);break;case"F2":e&&!r&&o&&(e.focus(),h=!0);break;case"Enter":i.setFocus(),(0===i.activeColIdx||u)&&c.isExpandable()?(c.setExpanded(!c.isExpanded()),h=!0):e&&!r&&o&&(e.focus(),h=!0);break;case"Escape":i.setFocus(),c.log("keynav: focus tree..."),i.isCellNav()&&l!==NavModeEnum.cell&&(c.log("keynav: setCellNav(false)"),i.setCellNav(!1),i.setFocus(),h=!0);break;case"ArrowLeft":i.setFocus(),u&&c.isExpanded()?c.setExpanded(!1):!u&&i.activeColIdx>0?i.setColumn(i.activeColIdx-1):l!==NavModeEnum.cell&&i.setCellNav(!1),h=!0;break;case"ArrowRight":i.setFocus(),u&&!c.isExpanded()?c.setExpanded():!u&&i.activeColIdx<i.columns.length-1&&i.setColumn(i.activeColIdx+1),h=!0;break;case"Home":i.setFocus(),!u&&i.activeColIdx>0&&i.setColumn(0),h=!0;break;case"End":i.setFocus(),!u&&i.activeColIdx<i.columns.length-1&&i.setColumn(i.columns.length-1),h=!0;break;case"ArrowDown":case"ArrowUp":case"Backspace":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":c.navigate(d,{activate:n,event:t}),h=!0;break;default:h=!1}}h&&t.preventDefault()}}
33
33
  /*!
34
34
  * Wunderbaum - ext-logger
35
35
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
36
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
36
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
37
37
  */class LoggerExtension extends WunderbaumExtension{constructor(e){super(e,"logger",{}),this.ignoreEvents=new Set(["iconBadge","render","discard"]),this.prefix=e+".ext-logger"}init(){const e=this.tree;if(e.getOption("debugLevel")>=4){const t=this.ignoreEvents,i=this.prefix;overrideMethod(e,"callEvent",(function(s,n){if(t.has(s))return e._superApply(arguments);const r=Date.now(),o=e._superApply(arguments);return e.logDebug(`${i}: callEvent('${s}') took ${Date.now()-r} ms.`,arguments[1]),o}))}}onKeyEvent(e){this.tree.logDebug(`${this.prefix}: onKeyEvent()`,e)}}
38
38
  /*!
39
39
  * Wunderbaum - common
40
40
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
41
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
41
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
42
42
  */const DEFAULT_DEBUGLEVEL=3,ROW_HEIGHT=22,ICON_WIDTH=20,TITLE_SPAN_PAD_Y=7,RENDER_MAX_PREFETCH=5,TEST_IMG=new RegExp(/\.|\//),iconMaps={bootstrap:{error:"bi bi-exclamation-triangle",loading:"bi bi-chevron-right wb-busy",noData:"bi bi-question-circle",expanderExpanded:"bi bi-chevron-down",expanderCollapsed:"bi bi-chevron-right",expanderLazy:"bi bi-chevron-right wb-helper-lazy-expander",checkChecked:"bi bi-check-square",checkUnchecked:"bi bi-square",checkUnknown:"bi bi-dash-square-dotted",radioChecked:"bi bi-circle-fill",radioUnchecked:"bi bi-circle",radioUnknown:"bi bi-record-circle",folder:"bi bi-folder2",folderOpen:"bi bi-folder2-open",folderLazy:"bi bi-folder-symlink",doc:"bi bi-file-earmark"},fontawesome6:{error:"fa-solid fa-triangle-exclamation",loading:"fa-solid fa-chevron-right fa-beat",noData:"fa-solid fa-circle-question",expanderExpanded:"fa-solid fa-chevron-down",expanderCollapsed:"fa-solid fa-chevron-right",expanderLazy:"fa-solid fa-chevron-right wb-helper-lazy-expander",checkChecked:"fa-regular fa-square-check",checkUnchecked:"fa-regular fa-square",checkUnknown:"fa-regular fa-square-minus",radioChecked:"fa-solid fa-circle",radioUnchecked:"fa-regular fa-circle",radioUnknown:"fa-regular fa-circle-question",folder:"fa-solid fa-folder-closed",folderOpen:"fa-regular fa-folder-open",folderLazy:"fa-solid fa-folder-plus",doc:"fa-regular fa-file"}},RESERVED_TREE_SOURCE_KEYS=new Set(["_format","_keyMap","_positional","_typeList","_version","children","columns","types"]),KEY_TO_ACTION_DICT={" ":"toggleSelect","+":"expand",Add:"expand",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"parent","/":"collapseAll",Divide:"collapseAll",End:"lastCol",Home:"firstCol","Control+End":"last","Control+Home":"first","Meta+ArrowDown":"last","Meta+ArrowUp":"first","*":"expandAll",Multiply:"expandAll",PageDown:"pageDown",PageUp:"pageUp","-":"collapse",Subtract:"collapse"};function makeNodeTitleMatcher(e){return e instanceof RegExp?function(t){return e.test(t.title)}:(assert("string"==typeof e),function(t){return t.title===e})}function makeNodeTitleStartMatcher(e){e=escapeRegex(e);const t=new RegExp("^"+e,"i");return function(e){return t.test(e.title)}}function nodeTitleSorter(e,t){const i=e.title.toLowerCase(),s=t.title.toLowerCase();return i===s?0:i>s?1:-1}function unflattenSource(e){var t,i,s;const{_format:n,_keyMap:r,_positional:o,children:l}=e;if("flat"!==n)throw new Error(`Expected source._format: "flat", but got ${n}`);if(o&&o.includes("children"))throw new Error(`source._positional must not include "children": ${o}`);const a={};if(r)for(const[e,t]of Object.entries(r))a[t]=e;const d=o.map((e=>a[e])),c=[],h={},u={},p=null!==(t=a.key)&&void 0!==t?t:"key",g=null!==(i=a.children)&&void 0!==i?i:"children";for(const[e,t]of l.entries()){const[i,n,r={}]=t;t[1]=null,null!=t[2]&&(t[2]=null),n.forEach(((e,t)=>{r[d[t]]=e})),u[e]=r;const o=r[p];null!=o&&(h[o]=r);let l=null;if(null===i);else if("number"==typeof i){if(l=u[i],void 0===l)throw new Error(`unflattenSource: Could not find parent node by index: ${i}.`)}else if(l=h[i],void 0===l)throw new Error(`unflattenSource: Could not find parent node by key: ${i}`);l?(null!==(s=l[g])&&void 0!==s||(l[g]=[]),l[g].push(r)):c.push(r)}delete e.children,e.children=c}function inflateSourceData(e){const{_format:t,_keyMap:i,_typeList:s}=e;"flat"===t&&unflattenSource(e),delete e._format,delete e._version,delete e._keyMap,delete e._typeList,delete e._positional,function e(t){for(const n of t){i&&Object.getOwnPropertyNames(n).forEach((e=>{var t;const s=null!==(t=i[e])&&void 0!==t?t:e;s!==e&&(n[s]=n[e],delete n[e])}));const t=n.type;if(s&&null!=t&&"number"==typeof t){const e=s[t];if(null==e)throw new Error(`Expected typeList[${t}] entry in [${s}]`);n.type=e}n.children&&e(n.children)}}(e.children)}
43
43
  /*!
44
44
  * Wunderbaum - ext-dnd
45
45
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
46
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
46
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
47
47
  */const nodeMimeType="application/x-wunderbaum-node";class DndExtension extends WunderbaumExtension{constructor(e){super(e,"dnd",{autoExpandMS:1500,multiSource:!1,effectAllowed:"all",dropEffectDefault:"move",preventForeignNodes:!1,preventLazyParents:!0,preventNonNodes:!1,preventRecursion:!0,preventSameParent:!1,preventVoidMoves:!0,serializeClipboardData:!0,scroll:!0,scrollSensitivity:20,scrollSpeed:5,sourceCopyHook:null,dragStart:null,drag:null,dragEnd:null,dragEnter:null,dragOver:null,dragExpand:null,drop:null,dragLeave:null}),this.srcNode=null,this.lastTargetNode=null,this.lastEnterStamp=0,this.lastAllowedDropRegions=null,this.lastDropEffect=null,this.lastDropRegion=!1,this.currentScrollDir=0,this.applyScrollDirThrottled=throttle(this.applyScrollDir,50)}init(){super.init();const e=this.tree,t=e.options.dnd;t.dragStart&&onEvent(e.element,"dragstart drag dragend",this.onDragEvent.bind(this)),t.dragEnter&&onEvent(e.element,"dragenter dragover dragleave drop",this.onDropEvent.bind(this))}_leaveNode(){const e=this.lastTargetNode;this.lastEnterStamp=0,e&&(e.setClass("wb-drop-target wb-drop-over wb-drop-after wb-drop-before",!1),this.lastTargetNode=null)}unifyDragover(e){if(!1===e)return!1;if(e instanceof Set)return e.size>0&&e;if(!0===e)return new Set(["over","before","after"]);if("string"==typeof e||isArray(e))return(e=toSet(e)).size>0&&e;throw new Error("Unsupported drop region definition: "+e)}_calcDropRegion(e,t){const i=e.offsetY;return!!t&&(3===t.size?i<5.5?"before":i>16.5?"after":"over":1===t.size&&t.has("over")?"over":i>11?"after":"before")}applyScrollDir(){if(this.isDragging()&&this.currentScrollDir){const e=this.tree.options.dnd,t=this.tree.element,i=t.scrollTop;this.currentScrollDir<0?t.scrollTop=Math.max(0,i-e.scrollSpeed):this.currentScrollDir>0&&(t.scrollTop=i+e.scrollSpeed)}}autoScroll(e){const t=this.tree,i=t.options.dnd.scrollSensitivity,s=t.element,n=t.headerElement.clientHeight,r=s.offsetHeight,o=s.scrollTop;return this.currentScrollDir=0,o>0&&e>0&&e<=i+n?this.currentScrollDir=-1:o<s.scrollHeight-r&&e>=r-i&&(this.currentScrollDir=1),this.currentScrollDir&&this.applyScrollDirThrottled(),s.scrollTop-o}isDragging(){return!!this.srcNode}onDragEvent(e){const t=this.treeOpts.dnd,i=Wunderbaum.getNode(e);if(i){if("drag"!==e.type&&this.tree.logDebug("onDragEvent."+e.type+", srcNode: "+i,e),"dragstart"===e.type){if(e.dataTransfer.effectAllowed=t.effectAllowed,i.isEditing())return i.logDebug("Prevented dragging node in edit mode."),e.preventDefault(),!1;if(!i._callEvent("dnd.dragStart",{event:e}))return e.preventDefault(),!1;const s=i.toDict(!0,(e=>{e._org_key=e.key,delete e.key}));s._treeId=i.tree.id,t.serializeClipboardData&&("function"==typeof t.serializeClipboardData?e.dataTransfer.setData(nodeMimeType,t.serializeClipboardData(s)):e.dataTransfer.setData(nodeMimeType,JSON.stringify(s))),e.dataTransfer.setData("text/plain",i.title),this.srcNode=i,setTimeout((()=>{i.setClass("wb-drag-source")}),0)}else"drag"===e.type?t.drag&&i._callEvent("dnd.drag",{event:e}):"dragend"===e.type&&(i.setClass("wb-drag-source",!1),this.srcNode=null,this.lastTargetNode&&this._leaveNode(),t.dragEnd&&i._callEvent("dnd.dragEnd",{event:e}));return!0}}_isVoidDrop(e,t,i){return this.tree.logDebug(`_isVoidDrop: ${t} -> ${i} ${e}`),!(!this.treeOpts.dnd.preventVoidMoves||!t)&&("before"===i&&e===t.getNextSibling()||"after"===i&&e===t.getPrevSibling()?(this.tree.logDebug("Prevented before/after self"),!0):t===e||t.parent===e)}onDropEvent(e){const t=this.srcNode,i=t?t.tree:null,s=Wunderbaum.getNode(e),n=this.treeOpts.dnd,r=e.dataTransfer,o=this._calcDropRegion(e,this.lastAllowedDropRegions);if(s){if(["dragenter","dragover","dragleave"].includes(e.type)||this.tree.logDebug("onDropEvent."+e.type+" targetNode: "+s+", ea: "+(null==r?void 0:r.effectAllowed)+", de: "+(null==r?void 0:r.dropEffect),", cy: "+e.offsetY,", r: "+o,", srcNode: "+t,e),"dragenter"===e.type){if(this.lastAllowedDropRegions=null,this.lastTargetNode&&this.lastTargetNode!==s&&this._leaveNode(),this.lastTargetNode=s,this.lastEnterStamp=Date.now(),s.isStatusNode()||n.preventForeignNodes&&s.tree!==i||n.preventLazyParents&&!s.isLoaded()||n.preventNonNodes&&!t||n.preventRecursion&&(null==t?void 0:t.isAncestorOf(s))||n.preventSameParent&&t&&s.parent===t.parent||n.preventVoidMoves&&s===t)return r.dropEffect="none",this.tree.log("Prevented drop operation"),!0;let o=s._callEvent("dnd.dragEnter",{event:e});return o=this.unifyDragover(o),o?(this.lastAllowedDropRegions=o,this.lastDropEffect=r.dropEffect,s.setClass("wb-drop-target"),e.preventDefault(),!1):(r.dropEffect="none",!0)}if("dragover"===e.type){const i=e.clientY-this.tree.element.offsetTop;this.autoScroll(i),n.dragOver&&s._callEvent("dnd.dragOver",{event:e});const r=this._calcDropRegion(e,this.lastAllowedDropRegions);if(this.lastDropRegion=r,n.autoExpandMS>0&&s.isExpandable(!0)&&!s._isLoading&&Date.now()-this.lastEnterStamp>n.autoExpandMS&&!1!==s._callEvent("dnd.dragExpand",{event:e})&&s.setExpanded(),!r||this._isVoidDrop(s,t,r))return;return s.setClass("wb-drop-over","over"===r),s.setClass("wb-drop-before","before"===r),s.setClass("wb-drop-after","after"===r),e.preventDefault(),!1}if("dragleave"===e.type)n.dragLeave&&s._callEvent("dnd.dragLeave",{event:e});else if("drop"===e.type){e.stopPropagation(),this._leaveNode();const t=this.lastDropRegion;s._callEvent("dnd.drop",{event:e,region:t,defaultDropMode:"over"===t?"appendChild":t,sourceNode:this.srcNode})}}else this._leaveNode()}}
48
48
  /*!
49
49
  * Wunderbaum - drag_observer
50
50
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
51
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
51
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
52
52
  */class DragObserver{constructor(e){if(this.start={x:0,y:0,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},this.dragElem=null,this.dragging=!1,this.events=["mousedown","mouseup","mousemove","keydown"],!e.root)throw new Error("Missing `root` option.");this.opts=Object.assign({thresh:5},e),this.root=e.root,this._handler=this.handleEvent.bind(this),this.events.forEach((e=>{this.root.addEventListener(e,this._handler)}))}disconnect(){this.events.forEach((e=>{this.root.removeEventListener(e,this._handler)}))}getDragElem(){return this.dragElem}isDragging(){return this.dragging}stopDrag(e){this.dragging&&this.opts.dragstop&&e&&(e.type="dragstop",this.opts.dragstop(e)),this.dragElem=null,this.dragging=!1}handleEvent(e){const t=e.type,i=this.opts,s={type:e.type,event:e,dragElem:this.dragElem,dx:e.pageX-this.start.x,dy:e.pageY-this.start.y,apply:void 0};switch(t){case"keydown":this.stopDrag(s);break;case"mousedown":if(this.dragElem){this.stopDrag(s);break}if(i.selector){let t=e.target;if(t.matches(i.selector))this.dragElem=t;else{if(t=t.closest(i.selector),!t)break;this.dragElem=t}}this.start.x=e.pageX,this.start.y=e.pageY,this.start.altKey=e.altKey,this.start.ctrlKey=e.ctrlKey,this.start.metaKey=e.metaKey,this.start.shiftKey=e.shiftKey;break;case"mousemove":if(!this.dragElem)break;if(!this.dragging){if(i.thresh){if(s.dx*s.dx+s.dy*s.dy<i.thresh*i.thresh)break}if(s.type="dragstart",!1===i.dragstart(s)){this.stopDrag(s);break}this.dragging=!0}this.dragging&&this.opts.drag&&(s.type="drag",this.opts.drag(s));break;case"mouseup":if(!this.dragging){this.stopDrag(s);break}0===e.button?s.apply=!0:s.apply=!1,this.stopDrag(s)}}}
53
53
  /*!
54
54
  * Wunderbaum - ext-grid
55
55
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
56
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
56
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
57
57
  */class GridExtension extends WunderbaumExtension{constructor(e){super(e,"grid",{}),this.observer=new DragObserver({root:window.document,selector:"span.wb-col-resizer",thresh:4,dragstart:e=>this.tree.element.contains(e.dragElem),drag:e=>this.handleDrag(e),dragstop:e=>this.handleDrag(e)})}init(){super.init()}handleDrag(e){const t=Wunderbaum.getEventInfo(e.event);this.tree.log(`${e.type}(${e.dx})`,e,t)}}
58
58
  /*!
59
59
  * Wunderbaum - deferred
60
60
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
61
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
61
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
62
62
  */class Deferred{constructor(){this._promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){this._resolve(e)}reject(e){this._reject(e)}promise(){return this._promise}then(e){return this._promise.then(e)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}}
63
63
  /*!
64
64
  * Wunderbaum - wunderbaum_node
65
65
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
66
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
66
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
67
67
  */const NODE_PROPS=new Set(["checkbox","classes","expanded","icon","iconTooltip","key","lazy","_partsel","radiogroup","refKey","selected","statusNodeType","title","tooltip","type","unselectable"]),NODE_DICT_PROPS=new Set(NODE_PROPS);NODE_DICT_PROPS.delete("_partsel"),NODE_DICT_PROPS.delete("unselectable");class WunderbaumNode{constructor(e,t,i){var s,n;this.refKey=void 0,this.children=null,this.classes=null,this.data={},this._isLoading=!1,this._requestId=0,this._errorInfo=null,this._partsel=!1,this._partload=!1,this.subMatchCount=0,this._rowIdx=0,this._rowElem=void 0,assert(!t||t.tree===e),assert(!i.children),this.tree=e,this.parent=t,this.key=""+(null!==(s=i.key)&&void 0!==s?s:++WunderbaumNode.sequence),this.title=""+(null!==(n=i.title)&&void 0!==n?n:"<"+this.key+">"),null!=i.refKey&&(this.refKey=""+i.refKey),null!=i.type&&(this.type=""+i.type),this.expanded=!0===i.expanded,null!=i.icon&&(this.icon=i.icon),this.lazy=!0===i.lazy,null!=i.statusNodeType&&(this.statusNodeType=""+i.statusNodeType),null!=i.colspan&&(this.colspan=!!i.colspan),null!=i.checkbox&&(this.checkbox=!!i.checkbox),null!=i.radiogroup&&(this.radiogroup=!!i.radiogroup),this.selected=!0===i.selected,!0===i.unselectable&&(this.unselectable=!0),i.classes&&this.setClass(i.classes);for(const[e,t]of Object.entries(i))NODE_PROPS.has(e)||(this.data[e]=t);t&&!this.statusNodeType&&e._registerNode(this)}toString(){return`WunderbaumNode@${this.key}<'${this.title}'>`}*[Symbol.iterator](){const e=this.children;if(e)for(let t=0,i=e.length;t<i;t++){const i=e[t];yield i,i.children&&(yield*i)}}_callEvent(e,t){return this.tree._callEvent(e,extend({node:this,typeInfo:this.type?this.tree.types[this.type]:{}},t))}addChildren(e,t){const i=this.tree;let{before:s=null,applyMinExpanLevel:n=!0,_level:r}=null!=t?t:{};null!=r||(r=this.getLevel());const o=[];try{i.enableUpdate(!1),isPlainObject(e)&&(e=[e]);const t=n&&r<i.options.minExpandLevel;for(const s of e){const e=s.children;delete s.children;const n=new WunderbaumNode(i,this,s);t&&!n.isUnloaded()&&(n.expanded=!0),o.push(n),e&&n.addChildren(e,{_level:r+1})}if(this.children)if(null==s||0===this.children.length)this.children=this.children.concat(o);else{s=this.findDirectChild(s);const e=this.children.indexOf(s);assert(e>=0,`options.before must be a direct child of ${this}`),this.children.splice(e,0,...o)}else this.children=o;i.update(ChangeType.structure)}finally{i.enableUpdate(!0)}return o[0]}addNode(e,t="appendChild"){switch("over"===t&&(t="appendChild"),t){case"after":return this.parent.addChildren(e,{before:this.getNextSibling()});case"before":return this.parent.addChildren(e,{before:this});case"prependChild":return this.addChildren(e,{before:0});case"appendChild":return this.addChildren(e)}assert(!1,"Invalid mode: "+t)}applyCommand(e,t){return this.tree.applyCommand(e,this,t)}collapseSiblings(e){for(const t of this.parent.children)t!==this&&t.expanded&&t.setExpanded(!1,e)}setClass(e,t=!0){const i=toSet(e);if(t)null===this.classes&&(this.classes=new Set),i.forEach((e=>{var i;this.classes.add(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)}));else{if(null===this.classes)return;i.forEach((e=>{var i;this.classes.delete(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)})),0===this.classes.size&&(this.classes=null)}}async expandAll(e=!0,t){const i=this.tree,s=this.tree.options.minExpandLevel,{depth:n=99,loadLazy:r,force:o,keepActiveNodeVisible:l=!0}=null!=t?t:{},a={scrollIntoView:!1,force:o,loadLazy:r};const d=i.logTime(`${this}.expandAll(${e})`);try{i.enableUpdate(!1),await async function t(i,n){var l;if(0===n)return;const d=null==n?null:n-1,c=[];return null===(l=i.children)||void 0===l||l.forEach((i=>{if(e)if(!i.expanded&&(i.children||r&&i.lazy)){const e=i.setExpanded(!0,a);c.push(e),e.then((async()=>{await t(i,d)}))}else c.push(t(i,d));else(!s||o||i.getLevel()>s)&&i.setExpanded(!1,a),t(i,d)})),new Promise((e=>{Promise.all(c).then((()=>{e(!0)}))}))}(this,n)}finally{i.enableUpdate(!0),i.logTimeEnd(d)}i.activeNode&&l&&i.activeNode.scrollIntoView()}findAll(e){const t="function"==typeof e?e:makeNodeTitleMatcher(e),i=[];return this.visit((e=>{t(e)&&i.push(e)})),i}findDirectChild(e){const t=this.children;if(!t)return null;if("string"==typeof e){for(let i=0,s=t.length;i<s;i++)if(t[i].key===e)return t[i]}else{if("number"==typeof e)return t[e];if(e.parent===this)return e}return null}findFirst(e){const t="function"==typeof e?e:makeNodeTitleMatcher(e);let i=null;return this.visit((e=>{if(t(e))return i=e,!1})),i}findRelatedNode(e,t=!1){return this.tree.findRelatedNode(this,e,t)}*format_iter(e,t){function i(e){const t=e.parent.children;return e===t[t.length-1]}null!=t||(t=[" "," | "," ╰─ "," ├─ "]),null!=e||(e=e=>""+e);const s=s=>{const n=[e(s)];n.unshift(t[i(s)?2:3]);let r=s.parent;for(;r&&r!==this;)n.unshift(t[i(r)?0:1]),r=r.parent;return n.join("")};yield e(this);for(const e of this)yield s(e)}format(e,t){const i=[];for(const s of this.format_iter(e,t))i.push(s);return i.join("\n")}getColElem(e){var t;"string"==typeof e&&(e=this.tree.columns.findIndex((t=>t.id===e)));const i=null===(t=this._rowElem)||void 0===t?void 0:t.querySelectorAll("span.wb-col");return i?i[e]:null}getFirstChild(){return this.children?this.children[0]:null}getLastChild(){return this.children?this.children[this.children.length-1]:null}getLevel(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}getNextSibling(){const e=this.parent.children,t=e.indexOf(this);return e[t+1]||null}getParent(){return this.parent}getParentList(e=!1,t=!1){const i=[];let s=t?this:this.parent;for(;s;)(e||s.parent)&&i.unshift(s),s=s.parent;return i}getPath(e=!0,t="title",i="/"){let s;const n=[],r="function"==typeof t;return this.visitParents((e=>{e.parent&&(s=r?t(e):e[t],n.unshift(s))}),e),n.join(i)}getPrevSibling(){const e=this.parent.children,t=e.indexOf(this);return e[t-1]||null}hasChildren(){if(this.lazy){if(null==this.children)return;if(0===this.children.length)return!1;if(1===this.children.length&&this.children[0].isStatusNode())return;return!0}return!(!this.children||!this.children.length)}hasClass(e){return!!this.classes&&this.classes.has(e)}isActive(){return this.tree.activeNode===this}isAncestorOf(e){return e&&e.isDescendantOf(this)}isChildOf(e){return e&&this.parent===e}isColspan(){return!!this.getOption("colspan")}isDescendantOf(e){if(!e||e.tree!==this.tree)return!1;let t=this.parent;for(;t;){if(t===e)return!0;t===t.parent&&error(`Recursive parent link: ${t}`),t=t.parent}return!1}isExpandable(e=!1){return!(e&&this.expanded||!1===this.children)&&(null==this.children?!!this.lazy:0!==this.children.length||!!this.tree.options.emptyChildListExpandable)}isEditing(){return this.tree._callMethod("edit.isEditingTitle",this)}isExpanded(){return!!this.expanded}isFirstSibling(){const e=this.parent;return!e||e.children[0]===this}isLastSibling(){const e=this.parent;return!e||e.children[e.children.length-1]===this}isLazy(){return!!this.lazy}isLoaded(){return!this.lazy||void 0!==this.hasChildren()}isLoading(){return this._isLoading}isPagingNode(){return"paging"===this.statusNodeType}isParentOf(e){return e&&e.parent===this}isPartload(){return!!this._partload}isPartsel(){return!this.selected&&!!this._partsel}isRadio(){return!!this.parent.radiogroup||"radio"===this.getOption("checkbox")}isRendered(){return!!this._rowElem}isRootNode(){return this.tree.root===this}isSelected(){return!!this.selected||!!this._partsel&&void 0}isStatusNode(){return!!this.statusNodeType}isTopLevel(){return this.tree.root===this.parent}isUnloaded(){return void 0===this.hasChildren()}isVisible(){const e="hide"===this.tree.filterMode,t=this.getParentList(!1,!1);if(e&&!this.match&&!this.subMatchCount)return!1;for(let e=0,i=t.length;e<i;e++){if(!t[e].expanded)return!1}return!0}_loadSourceObject(e,t){var i;const s=this.tree;null!=t||(t=this.getLevel());const n=this._callEvent("receive",{response:e});null!=n&&(e=n),isArray(e)&&(e={children:e}),assert(isPlainObject(e));const r=null!==(i=e.format)&&void 0!==i?i:"nested";assert("nested"===r||"flat"===r),inflateSourceData(e),assert(e.children,"If `source` is an object, it must have a `children` property"),e.types&&(s.logInfo("Redefine types",e.columns),s.setTypes(e.types,!1),delete e.types),e.columns&&(s.logInfo("Redefine columns",e.columns),s.columns=e.columns,delete e.columns,s.update(ChangeType.colStructure)),this.addChildren(e.children);for(const[t,i]of Object.entries(e))RESERVED_TREE_SOURCE_KEYS.has(t)||(s.data[t]=i);"hier"===s.options.selectMode&&this.fixSelection3FromEndNodes(),this._callEvent("load")}async _fetchWithOptions(e){var t,i;let s,n,r,o,l,a={};"string"==typeof e?(s=e,a.method="GET"):isPlainObject(e)?(({url:s,params:n,body:r,options:o,...l}=e),assert(!l||0===Object.keys(l).length,`Unexpected source properties: ${Object.keys(l)}. Use 'options' instead.`),assert("string"==typeof s,"expected source.url as string"),isPlainObject(o)&&(a=o),isPlainObject(r)&&(assert(!a.body,"options.body should be passed as source.body"),a.body=JSON.stringify(a.body),null!==(t=a.method)&&void 0!==t||(a.method="POST")),isPlainObject(n)&&(s+="?"+new URLSearchParams(n),null!==(i=a.method)&&void 0!==i||(a.method="GET"))):(s="",error(`Unsupported source format: ${e}`)),this.setStatus(NodeStatusType.loading);const d=await fetch(s,a);return d.ok||error(`GET ${s} returned ${d.status}, ${d}`),await d.json()}async load(e){const t=this.tree,i=Date.now(),s=this.parent,n=Date.now();let r=0,o=0,l=0;this._requestId&&this.logWarn(`Recursive load request #${i} while #${this._requestId} is pending.`),this._requestId=i;try{if("string"==typeof e?e:e.url){const t=await this._fetchWithOptions(e);if(o=Date.now()-n,this._requestId&&this._requestId>i)return void this.logWarn(`Ignored load response #${i} because #${this._requestId} is pending.`);if(this.logDebug(`Received response for load request #${i}`),null===this.parent&&null!==s)return void this.logWarn("Lazy parent node was removed while loading: discarding response.");this.setStatus(NodeStatusType.ok);const r=Date.now();this._loadSourceObject(t),l=Date.now()-r}else this._loadSourceObject(e),l=Date.now()-n}catch(t){throw this.logError("Error during load()",e,t),this._callEvent("error",{error:t}),this.setStatus(NodeStatusType.error,{message:""+t}),t}finally{this._requestId=0,r=Date.now()-n,t.options.debugLevel>=3&&t.logInfo(`Load source took ${r/1e3} seconds (transfer: ${o/1e3}s, processing: ${l/1e3}s)`)}}async loadLazy(e=!1){const t=this.expanded;if(assert(this.lazy,"load() requires a lazy node"),e||this.isUnloaded()){this.isLoaded()&&this.resetLazy(),this.setStatus(NodeStatusType.loading);try{const e=await this._callEvent("lazyLoad");if(!1===e)return void this.setStatus(NodeStatusType.ok);assert(isArray(e)||e&&e.url,"The lazyLoad event must return a node list, `{url: ...}`, or false."),await this.load(e),t?(this.expanded=!0,this.tree.update(ChangeType.structure)):this.update()}catch(e){this.logError("Error during loadLazy()",e),this._callEvent("error",{error:e}),this.setStatus(NodeStatusType.error,{message:""+e})}}}log(...e){this.logDebug(...e)}logDebug(...e){this.tree.options.debugLevel>=4&&console.log(this.toString(),...e)}logError(...e){this.tree.options.debugLevel>=1&&console.error(this.toString(),...e)}logInfo(...e){this.tree.options.debugLevel>=3&&console.info(this.toString(),...e)}logWarn(...e){this.tree.options.debugLevel>=2&&console.warn(this.toString(),...e)}async makeVisible(e){let t;const i=new Deferred,s=[],n=this.getParentList(!1,!1),r=n.length,o=getOption(e,"noAnimation",!1),l=getOption(e,"scrollIntoView",!0);for(t=r-1;t>=0;t--){const e={noAnimation:o};s.push(n[t].setExpanded(!0,e))}return Promise.all(s).then((()=>{l&&this.tree?(this.tree.updatePendingModifications(),this.scrollIntoView().then((()=>{i.resolve()}))):i.resolve()})),i.promise()}moveTo(e,t="appendChild",i){let s;"over"===t&&(t="appendChild"),"prependChild"===t&&(e.children&&e.children.length?(t="before",e=e.children[0]):t="appendChild");const n=this.tree,r=this.parent,o="appendChild"===t?e:e.parent;if(this!==e){if(this.parent?o.isDescendantOf(this)&&error("Cannot move a node to its own descendant"):error("Cannot move system root"),o!==r&&r.triggerModifyChild("remove",this),1===this.parent.children.length){if(this.parent===o)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else s=this.parent.children.indexOf(this),assert(s>=0,"invalid source parent"),this.parent.children.splice(s,1);if(this.parent=o,o.hasChildren())switch(t){case"appendChild":o.children.push(this);break;case"before":s=o.children.indexOf(e),assert(s>=0,"invalid target parent"),o.children.splice(s,0,this);break;case"after":s=o.children.indexOf(e),assert(s>=0,"invalid target parent"),o.children.splice(s+1,0,this);break;default:error(`Invalid mode '${t}'.`)}else o.children=[this];i&&e.visit(i,!0),o===r?o.triggerModifyChild("move",this):o.triggerModifyChild("add",this),n!==e.tree&&(this.logWarn("Cross-tree moveTo is experimental!"),this.visit((t=>{t.tree=e.tree}),!0)),setTimeout((()=>{n.update(ChangeType.any)}),0)}}async navigate(e,t){e=KEY_TO_ACTION_DICT[e]||e;const i=this.findRelatedNode(e);if(!i)return this.logWarn(`Could not find related node '${e}'.`),Promise.resolve(this);try{i.makeVisible({scrollIntoView:!1})}catch(e){}return i.setFocus(),!1===(null==t?void 0:t.activate)?Promise.resolve(this):i.setActive(!0,{event:null==t?void 0:t.event})}remove(){const e=this.tree,t=this.parent.children.indexOf(this);this.triggerModify("remove"),this.parent.children.splice(t,1),this.visit((t=>{t.removeMarkup(),e._unregisterNode(t)}),!0),e.update(ChangeType.structure)}removeChildren(){const e=this.tree;this.children&&(e.activeNode&&e.activeNode.isDescendantOf(this)&&e.activeNode.setActive(!1),e.focusNode&&e.focusNode.isDescendantOf(this)&&(e.focusNode=null),this.triggerModifyChild("remove",null),this.visit((t=>{e._unregisterNode(t)})),this.lazy?this.children=[]:this.children=null,this.isRootNode()||(this.expanded=!1),this.tree.update(ChangeType.structure))}removeMarkup(){this._rowElem&&(delete this._rowElem._wb_node,this._rowElem.remove(),this._rowElem=void 0)}_getRenderInfo(){const e={},t={},i=this.isColspan(),s=this._rowElem?this._rowElem.querySelectorAll("span.wb-col"):null;let n=0;for(const r of this.tree.columns)e[r.id]={id:r.id,idx:n,elem:s?s[n]:null,info:r},i||"*"===r.id||(t[r.id]=e[r.id]),n++;return{allColInfosById:e,renderColInfosById:t}}_createIcon(e,t,i,s){let n,r=this.getOption("icon");if(this._errorInfo?r=e.error:this._isLoading&&s&&(r=e.loading),!1===r)return null;"string"==typeof r||(r=this.statusNodeType?e[this.statusNodeType]:this.expanded?e.folderOpen:this.children?e.folder:this.lazy?e.folderLazy:e.doc),r?r.indexOf("<")>=0?n=elemFromHtml(r):TEST_IMG.test(r)?n=elemFromHtml(`<i class="wb-icon" style="background-image: url('${r}');">`):(n=document.createElement("i"),n.className="wb-icon "+r):(n=document.createElement("i"),n.className="wb-icon"),i?t.replaceChild(n,i):t.appendChild(n);const o=this._callEvent("iconBadge",{iconSpan:n});let l=null;if(null!=o&&!1!==o){let e="",t="";isPlainObject(o)?(l=""+o.badge,e=o.badgeClass?" "+o.badgeClass:"",t=o.badgeTooltip?` title="${o.badgeTooltip}"`:""):l="number"==typeof o?""+o:o,"string"==typeof l&&(l=elemFromHtml(`<span class="wb-badge${e}"${t}>${escapeHtml(l)}</span>`)),l&&n.append(l)}return n}_render_markup(e){const t=this.tree,i=t.options,s=this.getOption("checkbox"),n=t.columns,r=this.getLevel(),o=t.isRowNav()?null:t.activeColIdx;let l,a=this._rowElem,d=null,c=null;const h=!a;assert(h),assert(!h||e&&e.after,"opts.after expected, unless updating"),assert(!this.isRootNode()),a=document.createElement("div"),a.classList.add("wb-row"),a.style.top=22*this._rowIdx+"px",this._rowElem=a,a._wb_node=this;const u=document.createElement("span");u.classList.add("wb-node","wb-col"),a.appendChild(u);let p=0;s&&(d=document.createElement("i"),d.classList.add("wb-checkbox"),("radio"===s||this.parent.radiogroup)&&d.classList.add("wb-radio"),u.appendChild(d),p+=20);for(let e=r-1;e>0;e--)l=document.createElement("i"),l.classList.add("wb-indent"),u.appendChild(l),p+=20;(!i.minExpandLevel||r>i.minExpandLevel)&&(c=document.createElement("i"),c.classList.add("wb-expander"),u.appendChild(c),p+=20);this._createIcon(t.iconMap,u,null,!c)&&(p+=20);const g=document.createElement("span");g.classList.add("wb-title"),u.appendChild(g),u._ofsTitlePx=p,t.options.dnd.dragStart&&(u.draggable=!0);if(!this.isColspan()&&n.length>1){let e=0;for(const t of n){let i;e++,"*"===t.id?i=u:(i=document.createElement("span"),i.classList.add("wb-col"),a.appendChild(i)),e===o&&i.classList.add("wb-active"),t.classes&&i.classList.add(...t.classes.split(" ")),i.style.left=t._ofsPx+"px",i.style.width=t._widthPx+"px",h&&t.html&&"string"==typeof t.html&&(i.innerHTML=t.html)}}switch(e?e.after:"last"){case"first":t.nodeListElement.prepend(a);break;case"last":t.nodeListElement.appendChild(a);break;default:e.after.after(a)}e.isNew=!0,this._render_data(e)}_render_data(e){assert(this._rowElem);const t=this.tree,i=t.options,s=this._rowElem,n=!!e.isNew,r=!!e.preventScroll,o=t.columns,l=this.isColspan(),a=s.querySelector("span.wb-node"),d=a.querySelector("span.wb-title"),c=t.element.scrollTop;if(this.titleWithHighlight?d.innerHTML=this.titleWithHighlight:d.textContent=this.title,r&&(t.element.scrollTop=c),!i.skeleton)if(l){const e=t.element.clientWidth;d.style.width=e-a._ofsTitlePx-7+"px"}else d.style.width=o[0]._widthPx-a._ofsTitlePx-7+"px";if(e.isDataChange=!0,this._render_status(e),this.statusNodeType)this._callEvent("renderStatusNode",{isNew:n,nodeElem:a,isColspan:l});else if(this.parent){const e=this._getRenderInfo();this._callEvent("render",{isNew:n,nodeElem:a,isColspan:l,allColInfosById:e.allColInfosById,renderColInfosById:e.renderColInfosById})}}_render_status(e){const t=this.tree,i=t.iconMap,s=t.options,n=this.type?t.types[this.type]:null,r=this._rowElem,o=r.querySelector("span.wb-node"),l=o.querySelector("i.wb-expander"),a=o.querySelector("i.wb-checkbox"),d=["wb-row"];if(this.expanded&&d.push("wb-expanded"),this.lazy&&d.push("wb-lazy"),this.selected&&d.push("wb-selected"),this._partsel&&d.push("wb-partsel"),this===t.activeNode&&d.push("wb-active"),this===t.focusNode&&d.push("wb-focus"),this._errorInfo&&d.push("wb-error"),this._isLoading&&d.push("wb-loading"),this.isColspan()&&d.push("wb-colspan"),this.statusNodeType&&d.push("wb-status-"+this.statusNodeType),this.match&&d.push("wb-match"),this.subMatchCount&&d.push("wb-submatch"),s.skeleton&&d.push("wb-skeleton"),r.className=d.join(" "),this.classes&&r.classList.add(...this.classes),n&&n.classes&&r.classList.add(...n.classes),l){let e=null;this._isLoading?e=i.loading:this.isExpandable(!1)?e=this.expanded?i.expanderExpanded:i.expanderCollapsed:this.lazy&&null==this.children&&(e=i.expanderLazy),null==e?l.classList.add("wb-indent"):TEST_IMG.test(e)?l.style.backgroundImage=`url('${e}')`:l.className="wb-expander "+e}if(a){let e="wb-checkbox ";this.isRadio()?(e+="wb-radio ",this.selected?e+=i.radioChecked:e+=i.radioUnchecked):this.selected?e+=i.checkChecked:this._partsel?e+=i.checkUnknown:e+=i.checkUnchecked,a.className=e}if(!e.isNew){let e=0;for(const i of r.children)i.classList.toggle("wb-active",e++===t.activeColIdx);const i=o.querySelector("i.wb-icon");i&&this._createIcon(t.iconMap,o,i,!l)}if(!1!==e.resizeCols&&!this.isColspan()){const e=r.querySelectorAll("span.wb-col");let t=0,i=0;for(const s of this.tree.columns){const n=e[t];n.style.left=`${i}px`,n.style.width=`${s._widthPx}px`,t++,i+=s._widthPx}}}_render(e){const t=Object.assign({change:ChangeType.data},e);switch(this._rowElem||(t.change=ChangeType.row),t.change){case"status":this._render_status(t);break;case"data":this._render_data(t);break;case"row":this._render_markup(t);break;default:error(`Invalid change type '${t.change}'.`)}}resetLazy(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=null,this.tree.update(ChangeType.structure)}toDict(e=!1,t){const i={};if(NODE_DICT_PROPS.forEach((e=>{const t=this[e];t instanceof Set?t.size&&(i[e]=Array.prototype.join.call(t.keys()," ")):(t||!1===t||0===t)&&(i[e]=t)})),isEmptyObject(this.data)||(i.data=extend({},this.data),isEmptyObject(i.data)&&delete i.data),t){const s=t(i,this);if(!1===s)return!1;"skip"===s&&(e=!1)}if(e&&isArray(this.children)){i.children=[];for(let e=0,s=this.children.length;e<s;e++){const s=this.children[e];if(!s.isStatusNode()){const e=s.toDict(!0,t);!1!==e&&i.children.push(e)}}}return i}getOption(e,t){const i=this.tree;let s=i.options;e.indexOf(".")>=0&&([s,e]=e.split("."));const n=s[e];if("function"==typeof n){const e=n.call(i,{type:"resolve",tree:i,node:this});if(void 0!==e)return e}if(void 0!==this[e])return this[e];const r=this.type?i.types[this.type]:void 0,o=r?r[e]:void 0;return void 0!==o?o:null!=n?n:t}async scrollIntoView(e){const t=Object.assign({node:this},e);return this.tree.scrollTo(t)}async setActive(e=!0,t){const i=this.tree,s=i.activeNode,n=null==t?void 0:t.retrigger,r=null==t?void 0:t.focusTree,o=!1!==(null==t?void 0:t.focusNode),l=null==t?void 0:t.noEvents,a=null==t?void 0:t.event;if(!l)if(e){if(s!==this||n){if(!1===(null==s?void 0:s._callEvent("deactivate",{nextNode:this,event:a}))||!1===this._callEvent("beforeActivate",{prevNode:s,event:a}))return;i.activeNode=null,null==s||s.update(ChangeType.status)}}else(s===this||n)&&this._callEvent("deactivate",{nextNode:null,event:a});return s!==this&&(e&&(i.activeNode=this,(o||r)&&(i.focusNode=this),r&&i.setFocus()),null==s||s.update(ChangeType.status),this.update(ChangeType.status)),t&&null!=t.colIdx&&t.colIdx!==i.activeColIdx&&i.isCellNav()&&i.setColumn(t.colIdx),e&&!l&&this._callEvent("activate",{prevNode:s,event:a}),this.makeVisible()}async setExpanded(e=!0,t){const{force:i,scrollIntoView:s,immediate:n}=null!=t?t:{};if(!e&&this.isExpanded()&&this.getLevel()<=this.tree.getOption("minExpandLevel")&&!i)return void this.logDebug("Ignored collapse request below expandLevel.");if(!e==!this.expanded)return;e&&this.getOption("autoCollapse")&&this.collapseSiblings(t),e&&this.lazy&&null==this.children&&await this.loadLazy(),this.expanded=e;const r={immediate:n};if(this.tree.update(ChangeType.structure,r),e&&s){const e=this.getLastChild();e&&(this.tree.updatePendingModifications(),e.scrollIntoView({topNode:this}))}}setFocus(e=!0){assert(!!e,"blur is not yet implemented");const t=this.tree.focusNode;this.tree.focusNode=this,null==t||t.update(),this.update()}setIcon(e){this.icon=e,this.update()}setKey(e,t){throw new Error("Not yet implemented")}update(e=ChangeType.data){assert(e===ChangeType.status||e===ChangeType.data),this.tree.update(e,this)}getSelectedNodes(e=!1){const t=[];return this.visit((i=>{if(i.selected&&(t.push(i),!0===e))return"skip"})),t}toggleSelected(e){let t=this.isSelected();return t=void 0!==t||this.isRadio()?!t:this._anySelectable(),this.setSelected(t,e)}_anySelectable(){let e=!1;return this.visit((t=>{if(!1===t.selected&&!t.unselectable&&!t.hasChildren()&&!t.parent.radiogroup)return e=!0,!1})),e}_changeSelectStatusProps(e){let t=!1;switch(e){case!1:t=this.selected||this._partsel,this.selected=!1,this._partsel=!1;break;case!0:t=!this.selected||!this._partsel,this.selected=!0,this._partsel=!0;break;case void 0:t=this.selected||!this._partsel,this.selected=!1,this._partsel=!0;break;default:error(`Invalid state: ${e}`)}return t&&this.update(),t}fixSelection3AfterClick(e){const t=!!(null==e?void 0:e.force),i=this.isSelected();this.visit((e=>{if(e.radiogroup)return"skip";!t&&e.getOption("unselectable")||e._changeSelectStatusProps(i)})),this.fixSelection3FromEndNodes()}fixSelection3FromEndNodes(e){const t=!!(null==e?void 0:e.force);assert("hier"===this.tree.options.selectMode,"expected selectMode 'hier'");const i=e=>{let s;const n=e.children;if(n&&n.length){let e=!0,t=!1;for(let s=0,r=n.length;s<r;s++){const r=n[s],o=i(r);!1!==o&&(t=!0),!0!==o&&(e=!1)}s=!!e||!!t&&void 0}else s=!!e.selected;return e._partsel&&!e.selected&&e.lazy&&null==e.children&&(s=void 0),!t&&e.getOption("unselectable")||e._changeSelectStatusProps(s),s};i(this),this.visitParents((e=>{let t;const i=e.children;let s=!0,n=!1;for(let e=0,r=i.length;e<r;e++){const r=i[e];t=!!r.selected,(t||r._partsel)&&(n=!0),t||(s=!1)}t=!!s||!!n&&void 0,e._changeSelectStatusProps(t)}))}setSelected(e=!0,t){const i=this.tree,s=!(null==t?void 0:t.noEvents),n=this.isSelected(),r=this.parent&&this.parent.radiogroup,o=i.options.selectMode,l=(null==t?void 0:t.force)||!this.getOption("unselectable");return e=!!e,l?(null==t?void 0:t.propagateDown)&&"multi"===o?(i.runWithDeferredUpdate((()=>{this.visit((t=>{t.setSelected(e)}))})),n):(e===n||s&&!1===this._callEvent("beforeSelect",{flag:e})||(i.runWithDeferredUpdate((()=>{if(r){if(!e&&!(null==t?void 0:t.force))return n;for(const e of this.parent.children)e.selected=e===this}else this.selected=e,"hier"===o?this.fixSelection3AfterClick():"single"===o&&i.visit((e=>{e.selected=!1}))})),s&&this._callEvent("select",{flag:e})),n):n}setStatus(e,t){const i=this.tree,s=null==t?void 0:t.message,n=null==t?void 0:t.details;let r=null;const o=e=>{const t=this.children,s=t?t[0]:null;return assert(e.statusNodeType),assert(!s||!s.isStatusNode()),r=this.addNode(e,"prependChild"),r.match=!0,i.update(ChangeType.structure),r};switch((()=>{const e=this.children;e&&e.length&&e[0].isStatusNode()&&e[0].remove()})(),e){case"ok":this._isLoading=!1,this._errorInfo=null;break;case"loading":this._isLoading=!0,this._errorInfo=null,this.parent?this.update(ChangeType.status):o({statusNodeType:e,title:i.options.strings.loading+(s?" ("+s+")":""),checkbox:!1,colspan:!0,tooltip:n});break;case"error":o({statusNodeType:e,title:i.options.strings.loadError+(s?" ("+s+")":""),checkbox:!1,colspan:!0,tooltip:n}),this._isLoading=!1,this._errorInfo={message:s,details:n};break;case"noData":o({statusNodeType:e,title:s||i.options.strings.noData,checkbox:!1,colspan:!0,tooltip:n}),this._isLoading=!1,this._errorInfo=null;break;default:error("invalid node status "+e)}return i.update(ChangeType.structure),r}setTitle(e){this.title=e,this.update()}_sortChildren(e,t){const i=this.children;if(i&&(i.sort(e),t))for(let s=0,n=i.length;s<n;s++)i[s].children&&i[s]._sortChildren(e,t)}sortChildren(e=nodeTitleSorter,t=!1){this._sortChildren(e||nodeTitleSorter,t),this.tree.update(ChangeType.structure)}triggerModifyChild(e,t,i){this.logDebug(`modifyChild(${e})`,i,t),this.tree.options.modifyChild&&(t&&t.parent!==this&&error("child "+t+" is not a child of "+this),this._callEvent("modifyChild",extend({operation:e,child:t},i)))}triggerModify(e,t){this.parent.triggerModifyChild(e,this,t)}visit(e,t=!1){let i=!0;const s=this.children;if(!0===t&&(i=e(this),!1===i||"skip"===i))return i;if(s)for(let t=0,n=s.length;t<n&&(i=s[t].visit(e,!0),!1!==i);t++);return i}visitParents(e,t=!1){if(t&&!1===e(this))return!1;let i=this.parent;for(;i;){if(!1===e(i))return!1;i=i.parent}return!0}visitSiblings(e,t=!1){const i=this.parent.children;for(let s=0,n=i.length;s<n;s++){const n=i[s];if((t||n!==this)&&!1===e(n))return!1}return!0}isMatched(){return!(this.tree.filterMode&&!this.match)}}WunderbaumNode.sequence=0;
68
68
  /*!
69
69
  * Wunderbaum - ext-edit
70
70
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
71
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
71
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
72
72
  */
73
73
  class EditExtension extends WunderbaumExtension{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxlength:null,trigger:[],trim:!0,select:!0,slowClickDelay:1e3,validity:!0,beforeEdit:null,edit:null,apply:null}),this.curEditNode=null,this.relatedNode=null,this.debouncedOnChange=debounce(this._onChange.bind(this),this.getPluginOption("debounce"))}_applyChange(e,t,i,s){let n;t.log(`_applyChange(${e})`,s),i.classList.add("wb-busy"),i.classList.remove("wb-error");try{n=t._callEvent(e,s)}catch(s){t.logError(`Error in ${e} event handler`,s),i.classList.add("wb-error"),i.classList.remove("wb-busy")}return n instanceof Promise||(n=Promise.resolve(n)),n.catch((s=>{t.logError(`Error in ${e} event promise`,s),i.classList.add("wb-error")})).finally((()=>{i.classList.remove("wb-busy")})),n}_onChange(e){const t=Wunderbaum.getEventInfo(e),i=t.node,s=t.colElem;i&&0!==t.colIdx?this._applyChange("change",i,s,{info:t,event:e,inputElem:e.target,inputValue:Wunderbaum.util.getValueFromElem(e.target)}):this.tree.log("Ignored change event for removed element or node title")}init(){super.init(),onEvent(this.tree.element,"change",".contenteditable,input,textarea,select",(e=>{this.debouncedOnChange(e)}))}_preprocessKeyEvent(e){const t=e.event,i=eventToString(t),s=this.tree,n=this.getPluginOption("trigger");if(this.isEditingTitle()){switch(i){case"Enter":return this._stopEditTitle(!0,{event:t}),!1;case"Escape":return this._stopEditTitle(!1,{event:t}),!1}return!1}if(s.isRowNav()||0===s.activeColIdx){switch(i){case"Enter":if(n.indexOf("macEnter")>=0&&isMac)return this.startEditTitle(),!1;break;case"F2":if(n.indexOf("F2")>=0)return this.startEditTitle(),!1}return!0}return!0}isEditingTitle(e){return e?this.curEditNode===e:!!this.curEditNode}startEditTitle(e){e=null!=e?e:this.tree.getActiveNode();const t=this.getPluginOption("validity"),i=this.getPluginOption("select");if(!e)return;this.tree.logDebug(`startEditTitle(node=${e})`);let s=e._callEvent("edit.beforeEdit");if(!1===s)return void e.logInfo("beforeEdit canceled operation.");if(!0===s||!s){s=`<input type=text class="wb-input-edit" tabindex=-1 value="${escapeHtml(e.title)}" required autocorrect=off>`}const n=e.getColElem(0).querySelector(".wb-title");n.innerHTML=s;const r=n.firstElementChild;t&&r.addEventListener("keydown",(e=>{r.setCustomValidity(""),r.reportValidity()})),r.focus(),i&&r.select(),this.curEditNode=e,e._callEvent("edit.edit",{inputElem:r})}stopEditTitle(e){return this._stopEditTitle(e,{})}_stopEditTitle(e,t){null!=t||(t={});const i=document.activeElement;let s=i?getValueFromElem(i):null;const n=this.curEditNode,r=!!t.forceClose,o=this.getPluginOption("validity");if(s&&this.getPluginOption("trim")&&(s=s.trim()),n)if(n.logDebug(`stopEditTitle(${e})`,t,i,s),e&&null!==s&&s!==n.title){const e=i.validationMessage;if(e)throw new Error(`Input validation failed for "${s}": ${e}.`);const t=n.getColElem(0);this._applyChange("edit.apply",n,t,{oldValue:n.title,newValue:s,inputElem:i}).then((e=>{const t=i.validationMessage;if(o&&t&&!1!==e)throw new Error(`Edit apply validation failed for "${s}": ${t}.`);(r||!1!==e)&&(null==n||n.setTitle(s),this.curEditNode._render({preventScroll:!0}),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus())})).catch((e=>{n.logError(e)}))}else this.curEditNode._render({preventScroll:!0}),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus();else this.tree.logDebug("stopEditTitle: not in edit mode.")}createNode(e="after",t,i){const s=this.tree;if(assert(t=null!=t?t:s.getActiveNode(),"No node was passed, or no node is currently active."),e=e||"prependChild",null==i?i={title:""}:"string"==typeof i?i={title:i}:assert(isPlainObject(i)),("prependChild"===e||"appendChild"===e)&&(null==t?void 0:t.isExpandable(!0)))return void t.setExpanded().then((()=>{this.createNode(e,t,i)}));const n=t.addNode(i,e);n.setClass("wb-edit-new"),this.relatedNode=t,n.match=!0,n.makeVisible({noAnimation:!0}).then((()=>{this.startEditTitle(n)}))}}
74
74
  /*!
@@ -80,7 +80,7 @@ class EditExtension extends WunderbaumExtension{constructor(e){super(e,"edit",{d
80
80
  * https://github.com/mar10/wunderbaum
81
81
  *
82
82
  * Released under the MIT license.
83
- * @version v0.5.3
84
- * @date Sun, 15 Oct 2023 16:42:56 GMT
85
- */class WbSystemRoot extends WunderbaumNode{constructor(e){super(e,null,{key:"__root__",title:e.id})}toString(){return`WbSystemRoot@${this.key}<'${this.tree.id}'>`}}class Wunderbaum{constructor(e){this.enabled=!0,this.data={},this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.treeRowCount=0,this._disableUpdateCount=0,this._disableUpdateIgnoreCount=0,this.activeNode=null,this.focusNode=null,this.types={},this.columns=[],this._columnsById={},this.pendingChangeTypes=new Set,this._util=util,this.filterMode=null,this.activeColIdx=0,this._cellNavMode=!1,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this.log=this.logDebug;const t=this.options=extend({id:null,source:null,element:null,debugLevel:3,header:null,rowHeightPx:22,iconMap:"bootstrap",columns:null,types:null,enabled:!0,fixedCol:!1,showSpinner:!1,checkbox:!1,minExpandLevel:0,emptyChildListExpandable:!1,skeleton:!1,connectTopBreadcrumb:null,selectMode:"multi",navigationModeOption:null,quicksearch:!0,iconBadge:null,change:null,error:null,receive:null,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e),i=new Deferred;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){this.logError("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++Wunderbaum.sequence,this.root=new WbSystemRoot(this),this._registerExtension(new KeynavExtension(this)),this._registerExtension(new EditExtension(this)),this._registerExtension(new FilterExtension(this)),this._registerExtension(new DndExtension(this)),this._registerExtension(new GridExtension(this)),this._registerExtension(new LoggerExtension(this)),this._updateViewportThrottled=adaptiveThrottle(this._updateViewportImmediately.bind(this),{}),this.columns=t.columns,delete t.columns,!this.columns||!this.columns.length){const e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}t.types&&this.setTypes(t.types,!0),delete t.types,this.element=elemFromSelector(t.element),assert(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){assert(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||`col_${this.columns.length}`,title:""+t.textContent,width:"*"})}else{const e="<span class='wb-col'></span>".repeat(this.columns.length);if(this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`,!n){this.element.querySelector("div.wb-header").style.display="none"}}this.element.innerHTML+='\n <div class="wb-list-container">\n <div class="wb-node-list"></div>\n </div>',this.listContainerElement=this.element.querySelector("div.wb-list-container"),this.nodeListElement=this.listContainerElement.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.element.classList.toggle("wb-grid",this.columns.length>1),this._initExtensions(),["enabled","fixedCol"].forEach((e=>{null!=t[e]&&this.setOption(e,t[e])})),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{null==t.navigationModeOption?this.isGrid()?this.setNavigationOption(NavModeEnum.cell):this.setNavigationOption(NavModeEnum.row):this.setNavigationOption(t.navigationModeOption),i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),this.update(ChangeType.any),this.element.addEventListener("scroll",(e=>{this.update(ChangeType.scroll)})),this.resizeObserver=new ResizeObserver((e=>{this.update(ChangeType.resize)})),this.resizeObserver.observe(this.element),onEvent(this.nodeListElement,"click","div.wb-row",(t=>{const i=Wunderbaum.getEventInfo(t),s=i.node,n=t;if(!1===this._callEvent("click",{event:t,node:s,info:i}))return this.lastClickTime=Date.now(),!1;if(s){if(n.ctrlKey)return void s.toggleSelected();const r=this.getOption("edit.trigger"),o=this.getOption("edit.slowClickDelay");r.indexOf("clickActive")>=0&&"title"===i.region&&s.isActive()&&(!o||Date.now()-this.lastClickTime<o)&&this._callMethod("edit.startEditTitle",s),i.colIdx>=0?s.setActive(!0,{colIdx:i.colIdx,event:t}):s.setActive(!0,{event:t}),i.region===NodeRegion.expander?s.setExpanded(!s.isExpanded(),{scrollIntoView:!1!==e.scrollIntoViewOnExpandClick}):i.region===NodeRegion.checkbox&&s.toggleSelected()}this.lastClickTime=Date.now()})),onEvent(this.nodeListElement,"dblclick","div.wb-row",(e=>{const t=Wunderbaum.getEventInfo(e),i=t.node;if(!1===this._callEvent("dblclick",{event:e,node:i,info:t}))return!1;i&&0===t.colIdx&&i.isExpandable()&&(this._callMethod("edit._stopEditTitle"),i.setExpanded(!i.isExpanded()))})),onEvent(this.element,"keydown",(e=>{const t=Wunderbaum.getEventInfo(e),i=eventToString(e),s=t.node||this.getFocusNode();this._callHook("onKeyEvent",{event:e,node:s,info:t,eventName:i})})),onEvent(this.element,"focusin focusout",(e=>{const i="focusin"===e.type,s=Wunderbaum.getNode(e);this._callEvent("focus",{flag:i,event:e}),i&&this.isRowNav()&&!this.isEditing()&&(t.navigationModeOption===NavModeEnum.row?null==s||s.setActive():this.setCellNav()),i||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof Wunderbaum)return e;if(e instanceof WunderbaumNode)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(const t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return assert(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}get iconMap(){const e=this.options.iconMap;return"string"==typeof e?iconMaps[e]:e}static getNode(e){if(!e)return null;if(e instanceof WunderbaumNode)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}*[Symbol.iterator](){yield*this.root}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(const e of this.extensionList)e.init()}_registerNode(e){const t=e.key;assert(null!=t&&!this.keyMap.has(t),`Missing or duplicate key: '${t}'.`),this.keyMap.set(t,e);const i=e.refKey;if(i){const t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,e.removeMarkup()}_callHook(e,t={}){let i;const s=extend({},{tree:this,options:this.options,result:void 0},t);for(const t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,extend({type:e,tree:this,util:this._util},t))}_getNodeByRowIdx(e){let t=null;return this.visitRows((i=>{if(i._rowIdx===e)return t=i,!1})),t}getTopmostVpNode(e=!0){const t=this.element.scrollTop;let i;return i=e?Math.ceil((t-1)/22):Math.floor(t/22),this._getNodeByRowIdx(i)}getLowestVpNode(e=!0){const t=this.element,i=this.headerElement.clientHeight,s=t.scrollTop,n=t.clientHeight-i;let r;return r=e?Math.floor((s+n)/22)-1:Math.ceil((s+n)/22)-1,r=Math.min(r,this.count(!0)-1),this._getNodeByRowIdx(r)}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof WunderbaumNode?s=t:(s=this.getActiveNode(),assert(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:error(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.treeRowCount=0,this.activeNode=null,this.focusNode=null,this.update(ChangeType.structure)}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(e.indexOf(".")>=0){const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}else switch(this.options[e]=t,e){case"checkbox":this.update(ChangeType.any);break;case"enabled":this.setEnabled(!!t);break;case"fixedCol":this.element.classList.toggle("wb-fixed-col",!!t)}}hasFocus(){return this.element.contains(document.activeElement)}hasHeader(){const e=this.options.header;return this.isGrid()?!1!==e:!!e}runWithDeferredUpdate(e,t=null){try{this.enableUpdate(!1);const t=e();return assert(!(t instanceof Promise)),t}finally{this.enableUpdate(!0)}}async expandAll(e=!0,t){await this.root.expandAll(e,t)}selectAll(e=!0){return this.root.setSelected(e,{propagateDown:!0})}toggleSelect(){this.selectAll(this.root._anySelectable())}getSelectedNodes(e=!1){return this.root.getSelectedNodes(e)}_selectRange(e){this.logDebug("_selectRange",e),error("Not yet implemented.")}count(e=!1){return e?this.treeRowCount:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findKey(e){return this.keyMap.get(e)||null}findNextNode(e,t){let i=null;const s=this.getFirstChild(),n="string"==typeof e?makeNodeTitleStartMatcher(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null;const n=Math.floor(this.listContainerElement.clientHeight/22);switch(t){case"parent":case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((e=>{if(e.isVisible())return s=e,!1}));break;case"last":this.visit((e=>{e.isVisible()&&(s=e)}));break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":{const t=this.getLowestVpNode();s=e._rowIdx<t._rowIdx?t:this._getNextNodeInView(e,n)}break;case"pageUp":if(0===e._rowIdx)s=e;else{const t=this.getTopmostVpNode();s=e._rowIdx>t._rowIdx?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}*format_iter(e,t){yield*this.root.format_iter(e,t)}format(e,t){return this.root.format(e,t)}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){const t=e.target,i=t.classList,s=t.closest("span.wb-col"),n=Wunderbaum.getNode(t),r=n?n.tree:Wunderbaum.getTree(e),o={event:e,canonicalName:eventToString(e),tree:r,node:n,region:NodeRegion.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))o.region=NodeRegion.title;else if(i.contains("wb-expander"))o.region=n.isExpandable()?NodeRegion.expander:NodeRegion.prefix;else if(i.contains("wb-checkbox"))o.region=NodeRegion.checkbox;else if(i.contains("wb-icon"))o.region=NodeRegion.icon;else if(i.contains("wb-node"))o.region=NodeRegion.title;else if(s){o.region=NodeRegion.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);o.colIdx=e}else{if(!i.contains("wb-row"))return"mousemove"===e.type||e instanceof KeyboardEvent||null==r||r.logWarn("getEventInfo(): not found",e,o),o;o.region=NodeRegion.title}return-1===o.colIdx&&(o.colIdx=0),o.colDef=null==r?void 0:r.columns[o.colIdx],null!=o.colDef&&(o.colId=o.colDef.id),o}toString(){return`Wunderbaum<'${this.id}'>`}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){let e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&console.log(this.toString(),...e)}logError(...e){this.options.debugLevel>=1&&console.error(this.toString(),...e)}logInfo(...e){this.options.debugLevel>=3&&console.info(this.toString(),...e)}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&console.warn(this.toString(),...e)}scrollTo(e){let t,i;e instanceof WunderbaumNode?t=e:(i=e,t=i.node),assert(t&&null!=t._rowIdx);const s=this.element,n=this.headerElement.clientHeight,r=s.scrollTop,o=s.clientHeight,l=22*t._rowIdx+n,a=n,d=l-r,c=d+22,h=null==i?void 0:i.topNode;let u=null;d>=a?c<=o||(u=l+22-o+2):u=l-a-2,null!=u&&(this.log(`scrollTo(${l}): ${r} => ${u}`),s.scrollTop=u,h&&this.scrollTo(h))}scrollToHorz(){const e=this.columns[0]._widthPx,t=this.element.clientWidth,i=this.element.scrollLeft,s=this.getActiveColElem(),n=Number.parseInt(null==s?void 0:s.style.left,10),r=n+Number.parseInt(null==s?void 0:s.style.width,10);let o=i;n-i<e?o=n-e:r-i>t&&(o=r-t),o=Math.max(0,o),this.log(`scrollToHorz(${this.activeColIdx}): ${n}..${r}, fixedOfs=${e}, vpWidth=${t}, curLeft=${i} -> ${o}`),this.element.scrollLeft=o}setColumn(e){var t;if(assert(this.isCellNav()),assert(0<=e&&e<this.columns.length),this.activeColIdx=e,this.hasHeader())for(const t of this.headerElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}null===(t=this.activeNode)||void 0===t||t.update(ChangeType.status);for(const t of this.nodeListElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}this.scrollToHorz()}setActiveNode(e,t=!0,i){var s;null===(s=this.findKey(e))||void 0===s||s.setActive(t,i)}setFocus(e=!0){e?this.element.focus():this.element.blur()}update(e,t,i){if(this._disableUpdateCount)return void this._disableUpdateIgnoreCount++;t instanceof WunderbaumNode||(i=t,t=null);const s=!!getOption(i,"immediate"),n=RenderFlag,r=this.pendingChangeTypes;switch(e){case ChangeType.any:case ChangeType.colStructure:r.add(n.header),r.add(n.clearMarkup),r.add(n.redraw),r.add(n.scroll);break;case ChangeType.resize:r.add(n.header),r.add(n.redraw);break;case ChangeType.structure:r.add(n.redraw);break;case ChangeType.scroll:r.add(n.scroll);break;case ChangeType.row:case ChangeType.data:case ChangeType.status:assert(t,`Option '${e}' requires a node.`),t._rowElem&&t._render({change:e});break;default:error(`Invalid change type '${e}'.`)}if(e===ChangeType.colStructure){const e=this.isGrid();this.element.classList.toggle("wb-grid",e),!e&&this.isCellNav()&&this.setCellNav(!1)}r.size>0&&(s?this._updateViewportImmediately():this._updateViewportThrottled())}setEnabled(e=!0){const t=this.enabled;return this.enabled=!!e,this.element.classList.toggle("wb-disabled",!e),t}isEnabled(){return this.enabled}isGrid(){return this.columns&&this.columns.length>1}isCellNav(){return!!this._cellNavMode}isRowNav(){return!this._cellNavMode}setCellNav(e=!0){var t;const i=this._cellNavMode;this._cellNavMode=!!e,e&&!i&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",e),null===(t=this.activeNode)||void 0===t||t.update(ChangeType.status)}setNavigationOption(e,t=!1){if(this.isGrid()||e===NavModeEnum.row)switch(this.options.navigationModeOption=e,e){case NavModeEnum.cell:this.setCellNav(!0);break;case NavModeEnum.row:this.setCellNav(!1);break;case NavModeEnum.startCell:t&&this.setCellNav(!0);break;case NavModeEnum.startRow:t&&this.setCellNav(!1);break;default:error(`Invalid mode '${e}'.`)}else this.logWarn("Plain trees only support row navigation mode.")}setStatus(e,t){return this.root.setStatus(e,t)}setTypes(e,t=!0){assert(isPlainObject(e)),t?this.types=e:extend(this.types,e);for(const e of Object.values(this.types))e.classes&&(e.classes=toSet(e.classes))}sortChildren(e=nodeTitleSorter,t=!1){this.root.sortChildren(e,t)}toDictArray(e){var t;return null!==(t=this.root.toDict(!0,e).children)&&void 0!==t?t:[]}_updateColumnWidths(){const e=this.element.clientWidth,t=this.columns,i=t[0];let s=0,n=0,r=0,o=!1;if("*"!==i.id)throw new Error(`First column must have id '*': got '${i.id}'.`);this._columnsById={};for(const e of t){this._columnsById[e.id]=e;const t=e.width;if("*"===e.id&&e!==i)throw new Error(`Column id '*' must be defined only once: '${e.title}'.`);if(t&&"*"!==t)if("number"==typeof t)e._weight=t,n+=t;else if("string"==typeof t&&t.endsWith("px")){e._weight=0;const i=parseFloat(t.slice(0,-2));e._widthPx!=i&&(o=!0,e._widthPx=i),r+=i}else error(`Invalid column width: ${t} (expected string ending with 'px' or number, e.g. "<num>px" or <int>).`);else e._weight=1,n+=1}const l=Math.max(0,e-r);let a=0;for(const e of t){let t;if(e._weight){const i=e.minWidth;t="number"==typeof i?i:"string"==typeof i&&i.endsWith("px")?parseFloat(i.slice(0,-2)):4;const s=Math.max(t,l*e._weight/n);e._widthPx!=s&&(o=!0,e._widthPx=s)}e._ofsPx=a,a+=e._widthPx}t[t.length-1]._widthPx-=0,s=a-0;const d=`${s}px`;return this.headerElement.style.width=d,this.listContainerElement.style.width=d,o}_renderHeaderMarkup(){assert(this.headerElement);const e=this.hasHeader();if(setElemDisplay(this.headerElement,e),!e)return;const t=this.columns.length,i=this.headerElement.querySelector(".wb-row");assert(i),i.innerHTML="<span class='wb-col'></span>".repeat(t);for(let e=0;e<t;e++){const s=this.columns[e],n=i.children[e];n.style.left=s._ofsPx+"px",n.style.width=s._widthPx+"px","string"==typeof s.headerClasses?s.headerClasses&&n.classList.add(...s.headerClasses.split(" ")):s.classes&&n.classList.add(...s.classes.split(" "));const r=escapeHtml(s.title||s.id);let o="";s.tooltip&&(o=escapeTooltip(s.tooltip),o=` title="${o}"`);let l="";e<t-1&&(l='<span class="wb-col-resizer"></span>'),n.innerHTML=`<span class="wb-col-title"${o}>${r}</span>${l}`,this.isCellNav()&&n.classList.toggle("wb-active",e===this.activeColIdx)}}updatePendingModifications(){this.pendingChangeTypes.size>0&&this._updateViewportImmediately()}_updateViewportImmediately(){var e;if(this._disableUpdateCount)return this.log(`_updateViewportImmediately() IGNORED (disable level: ${this._disableUpdateCount})`),void this._disableUpdateIgnoreCount++;const t=RenderFlag,i=new Set(this.pendingChangeTypes);this.pendingChangeTypes.clear();if(i.has(t.scroll)&&1===i.size)this._updateRows({newNodesOnly:!0});else{if(this.log("_updateViewportImmediately():",i),!1!==this.options.adjustHeight){let e=this.listContainerElement.clientHeight;const t=this.headerElement.clientHeight,i=this.element.clientHeight-t-1;Math.abs(e-i)>1&&(this.listContainerElement.style.height=i+"px",e=i)}i.has(t.clearMarkup)&&this.visit((e=>{e.removeMarkup()})),i.has(t.header)&&(this._updateColumnWidths(),this._renderHeaderMarkup()),this._updateRows()}if(this.options.connectTopBreadcrumb){let t=null===(e=this.getTopmostVpNode(!0))||void 0===e?void 0:e.getPath(!1,"title"," > ");t=t?t+" >":"",this.options.connectTopBreadcrumb.textContent=t}this._callEvent("update")}_updateRows(e){const t=!!(e=Object.assign({newNodesOnly:!1},e)).newNodesOnly,i=this.element.clientHeight,s=this.element.scrollTop;let n=Math.max(0,s/22-5);n=Math.floor(n),n%2&&n--;let r=Math.max(0,(s+i)/22+5);r=Math.ceil(r);const o=new Set;this.nodeListElement.childNodes.forEach((e=>{const t=e;o.add(t._wb_node)}));let l=0,a=0,d=!1,c="first";this.visitRows((function(e){const i=e._rowElem;e._rowIdx!==l&&(e._rowIdx=l,d=!0),l<n||l>r?i&&(c=i):i&&t?(o.delete(e),i.style.top=22*l+"px",c=i):(o.delete(e),i&&(i.style.top=22*l+"px"),e._render({top:a,after:c}),c=e._rowElem),l++,a+=22})),this.treeRowCount=l;for(const e of o)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=`${a}px`,d}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,o,l,a=0,d=!1===(t=t||{}).includeSelf,c=t.start||this.root.children[0];const h=!!t.includeHidden,u=!h&&"hide"===this.filterMode;for(n=c.parent;n;){for(o=n.children,s=o.indexOf(c)+a,assert(s>=0,`Could not find ${c} in parent's children: ${n}`),i=s;i<o.length;i++){if(c=o[i],c===l)return!1;if(!u||c.statusNodeType||c.match||c.subMatchCount){if(!d&&!1===e(c))return!1;if(d=!1,c.children&&c.children.length&&(h||c.expanded)&&(r=c.visit((t=>t!==l&&(!u||t.match||t.subMatchCount?!1!==e(t)&&(h||!t.children||t.expanded?void 0:"skip"):"skip")),!1),!1===r))return!1}}c=n,n=n.parent,a=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),assert(t.start,"`wrap` option requires `start`"),l=t.start,t.wrap=!1,n=this.root,a=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=t.start||this.root.children[0];const o=!!t.includeHidden;if(!1!==t.includeSelf&&!1===e(r))return!1;for(;;){if(n=r.parent,i=n.children,i[0]===r){if(r=n,!r.parent)break;i=n.children}else for(s=i.indexOf(r),r=i[s-1];(o||r.expanded)&&r.children&&r.children.length;)i=r.children,n=r,r=i[i.length-1];if((o||r.isVisible())&&!1===e(r))return!1}return!0}load(e){return this.clear(),this.root.load(e)}enableUpdate(e){e?(assert(this._disableUpdateCount>0,"enableUpdate(true) was called too often"),this._disableUpdateCount--,0===this._disableUpdateCount&&(this.logDebug(`enableUpdate(): active again. Re-painting to catch up with ${this._disableUpdateIgnoreCount} ignored update requests...`),this._disableUpdateIgnoreCount=0,this.update(ChangeType.any,{immediate:!0}))):this._disableUpdateCount++}filterNodes(e,t){return this.extensions.filter.filterNodes(e,t)}filterBranches(e,t){return this.extensions.filter.filterBranches(e,t)}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}Wunderbaum.sequence=0,Wunderbaum.version="v0.5.3",Wunderbaum.util=util;export{Wunderbaum};
83
+ * @version v0.5.4
84
+ * @date Sun, 15 Oct 2023 16:43:28 GMT
85
+ */class WbSystemRoot extends WunderbaumNode{constructor(e){super(e,null,{key:"__root__",title:e.id})}toString(){return`WbSystemRoot@${this.key}<'${this.tree.id}'>`}}class Wunderbaum{constructor(e){this.enabled=!0,this.data={},this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.treeRowCount=0,this._disableUpdateCount=0,this._disableUpdateIgnoreCount=0,this.activeNode=null,this.focusNode=null,this.types={},this.columns=[],this._columnsById={},this.pendingChangeTypes=new Set,this._util=util,this.filterMode=null,this.activeColIdx=0,this._cellNavMode=!1,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this.log=this.logDebug;const t=this.options=extend({id:null,source:null,element:null,debugLevel:3,header:null,rowHeightPx:22,iconMap:"bootstrap",columns:null,types:null,enabled:!0,fixedCol:!1,showSpinner:!1,checkbox:!1,minExpandLevel:0,emptyChildListExpandable:!1,skeleton:!1,connectTopBreadcrumb:null,selectMode:"multi",navigationModeOption:null,quicksearch:!0,iconBadge:null,change:null,error:null,receive:null,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e),i=new Deferred;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){this.logError("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++Wunderbaum.sequence,this.root=new WbSystemRoot(this),this._registerExtension(new KeynavExtension(this)),this._registerExtension(new EditExtension(this)),this._registerExtension(new FilterExtension(this)),this._registerExtension(new DndExtension(this)),this._registerExtension(new GridExtension(this)),this._registerExtension(new LoggerExtension(this)),this._updateViewportThrottled=adaptiveThrottle(this._updateViewportImmediately.bind(this),{}),this.columns=t.columns,delete t.columns,!this.columns||!this.columns.length){const e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}t.types&&this.setTypes(t.types,!0),delete t.types,this.element=elemFromSelector(t.element),assert(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){assert(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||`col_${this.columns.length}`,title:""+t.textContent,width:"*"})}else{const e="<span class='wb-col'></span>".repeat(this.columns.length);if(this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`,!n){this.element.querySelector("div.wb-header").style.display="none"}}this.element.innerHTML+='\n <div class="wb-list-container">\n <div class="wb-node-list"></div>\n </div>',this.listContainerElement=this.element.querySelector("div.wb-list-container"),this.nodeListElement=this.listContainerElement.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.element.classList.toggle("wb-grid",this.columns.length>1),this._initExtensions(),["enabled","fixedCol"].forEach((e=>{null!=t[e]&&this.setOption(e,t[e])})),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{null==t.navigationModeOption?this.isGrid()?this.setNavigationOption(NavModeEnum.cell):this.setNavigationOption(NavModeEnum.row):this.setNavigationOption(t.navigationModeOption),i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),this.update(ChangeType.any),this.element.addEventListener("scroll",(e=>{this.update(ChangeType.scroll)})),this.resizeObserver=new ResizeObserver((e=>{this.update(ChangeType.resize)})),this.resizeObserver.observe(this.element),onEvent(this.nodeListElement,"click","div.wb-row",(t=>{const i=Wunderbaum.getEventInfo(t),s=i.node,n=t;if(!1===this._callEvent("click",{event:t,node:s,info:i}))return this.lastClickTime=Date.now(),!1;if(s){if(n.ctrlKey)return void s.toggleSelected();const r=this.getOption("edit.trigger"),o=this.getOption("edit.slowClickDelay");r.indexOf("clickActive")>=0&&"title"===i.region&&s.isActive()&&(!o||Date.now()-this.lastClickTime<o)&&this._callMethod("edit.startEditTitle",s),i.colIdx>=0?s.setActive(!0,{colIdx:i.colIdx,event:t}):s.setActive(!0,{event:t}),i.region===NodeRegion.expander?s.setExpanded(!s.isExpanded(),{scrollIntoView:!1!==e.scrollIntoViewOnExpandClick}):i.region===NodeRegion.checkbox&&s.toggleSelected()}this.lastClickTime=Date.now()})),onEvent(this.nodeListElement,"dblclick","div.wb-row",(e=>{const t=Wunderbaum.getEventInfo(e),i=t.node;if(!1===this._callEvent("dblclick",{event:e,node:i,info:t}))return!1;i&&0===t.colIdx&&i.isExpandable()&&(this._callMethod("edit._stopEditTitle"),i.setExpanded(!i.isExpanded()))})),onEvent(this.element,"keydown",(e=>{const t=Wunderbaum.getEventInfo(e),i=eventToString(e),s=t.node||this.getFocusNode();this._callHook("onKeyEvent",{event:e,node:s,info:t,eventName:i})})),onEvent(this.element,"focusin focusout",(e=>{const i="focusin"===e.type,s=Wunderbaum.getNode(e);this._callEvent("focus",{flag:i,event:e}),i&&this.isRowNav()&&!this.isEditing()&&(t.navigationModeOption===NavModeEnum.row?null==s||s.setActive():this.setCellNav()),i||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof Wunderbaum)return e;if(e instanceof WunderbaumNode)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(const t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return assert(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}get iconMap(){const e=this.options.iconMap;return"string"==typeof e?iconMaps[e]:e}static getNode(e){if(!e)return null;if(e instanceof WunderbaumNode)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}*[Symbol.iterator](){yield*this.root}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(const e of this.extensionList)e.init()}_registerNode(e){const t=e.key;assert(null!=t&&!this.keyMap.has(t),`Missing or duplicate key: '${t}'.`),this.keyMap.set(t,e);const i=e.refKey;if(i){const t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,e.removeMarkup()}_callHook(e,t={}){let i;const s=extend({},{tree:this,options:this.options,result:void 0},t);for(const t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,extend({type:e,tree:this,util:this._util},t))}_getNodeByRowIdx(e){let t=null;return this.visitRows((i=>{if(i._rowIdx===e)return t=i,!1})),t}getTopmostVpNode(e=!0){const t=this.element.scrollTop;let i;return i=e?Math.ceil((t-1)/22):Math.floor(t/22),this._getNodeByRowIdx(i)}getLowestVpNode(e=!0){const t=this.element,i=this.headerElement.clientHeight,s=t.scrollTop,n=t.clientHeight-i;let r;return r=e?Math.floor((s+n)/22)-1:Math.ceil((s+n)/22)-1,r=Math.min(r,this.count(!0)-1),this._getNodeByRowIdx(r)}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof WunderbaumNode?s=t:(s=this.getActiveNode(),assert(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:error(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.treeRowCount=0,this.activeNode=null,this.focusNode=null,this.update(ChangeType.structure)}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(e.indexOf(".")>=0){const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}else switch(this.options[e]=t,e){case"checkbox":this.update(ChangeType.any);break;case"enabled":this.setEnabled(!!t);break;case"fixedCol":this.element.classList.toggle("wb-fixed-col",!!t)}}hasFocus(){return this.element.contains(document.activeElement)}hasHeader(){const e=this.options.header;return this.isGrid()?!1!==e:!!e}runWithDeferredUpdate(e,t=null){try{this.enableUpdate(!1);const t=e();return assert(!(t instanceof Promise)),t}finally{this.enableUpdate(!0)}}async expandAll(e=!0,t){await this.root.expandAll(e,t)}selectAll(e=!0){return this.root.setSelected(e,{propagateDown:!0})}toggleSelect(){this.selectAll(this.root._anySelectable())}getSelectedNodes(e=!1){return this.root.getSelectedNodes(e)}_selectRange(e){this.logDebug("_selectRange",e),error("Not yet implemented.")}count(e=!1){return e?this.treeRowCount:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findKey(e){return this.keyMap.get(e)||null}findNextNode(e,t){let i=null;const s=this.getFirstChild(),n="string"==typeof e?makeNodeTitleStartMatcher(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null;const n=Math.floor(this.listContainerElement.clientHeight/22);switch(t){case"parent":case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((e=>{if(e.isVisible())return s=e,!1}));break;case"last":this.visit((e=>{e.isVisible()&&(s=e)}));break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":{const t=this.getLowestVpNode();s=e._rowIdx<t._rowIdx?t:this._getNextNodeInView(e,n)}break;case"pageUp":if(0===e._rowIdx)s=e;else{const t=this.getTopmostVpNode();s=e._rowIdx>t._rowIdx?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}*format_iter(e,t){yield*this.root.format_iter(e,t)}format(e,t){return this.root.format(e,t)}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){const t=e.target,i=t.classList,s=t.closest("span.wb-col"),n=Wunderbaum.getNode(t),r=n?n.tree:Wunderbaum.getTree(e),o={event:e,canonicalName:eventToString(e),tree:r,node:n,region:NodeRegion.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))o.region=NodeRegion.title;else if(i.contains("wb-expander"))o.region=n.isExpandable()?NodeRegion.expander:NodeRegion.prefix;else if(i.contains("wb-checkbox"))o.region=NodeRegion.checkbox;else if(i.contains("wb-icon"))o.region=NodeRegion.icon;else if(i.contains("wb-node"))o.region=NodeRegion.title;else if(s){o.region=NodeRegion.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);o.colIdx=e}else{if(!i.contains("wb-row"))return"mousemove"===e.type||e instanceof KeyboardEvent||null==r||r.logWarn("getEventInfo(): not found",e,o),o;o.region=NodeRegion.title}return-1===o.colIdx&&(o.colIdx=0),o.colDef=null==r?void 0:r.columns[o.colIdx],null!=o.colDef&&(o.colId=o.colDef.id),o}toString(){return`Wunderbaum<'${this.id}'>`}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){let e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&console.log(this.toString(),...e)}logError(...e){this.options.debugLevel>=1&&console.error(this.toString(),...e)}logInfo(...e){this.options.debugLevel>=3&&console.info(this.toString(),...e)}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&console.warn(this.toString(),...e)}scrollTo(e){let t,i;e instanceof WunderbaumNode?t=e:(i=e,t=i.node),assert(t&&null!=t._rowIdx);const s=this.element,n=this.headerElement.clientHeight,r=s.scrollTop,o=s.clientHeight,l=22*t._rowIdx+n,a=n,d=l-r,c=d+22,h=null==i?void 0:i.topNode;let u=null;d>=a?c<=o||(u=l+22-o+2):u=l-a-2,null!=u&&(this.log(`scrollTo(${l}): ${r} => ${u}`),s.scrollTop=u,h&&this.scrollTo(h))}scrollToHorz(){const e=this.columns[0]._widthPx,t=this.element.clientWidth,i=this.element.scrollLeft,s=this.getActiveColElem(),n=Number.parseInt(null==s?void 0:s.style.left,10),r=n+Number.parseInt(null==s?void 0:s.style.width,10);let o=i;n-i<e?o=n-e:r-i>t&&(o=r-t),o=Math.max(0,o),this.log(`scrollToHorz(${this.activeColIdx}): ${n}..${r}, fixedOfs=${e}, vpWidth=${t}, curLeft=${i} -> ${o}`),this.element.scrollLeft=o}setColumn(e){var t;if(assert(this.isCellNav()),assert(0<=e&&e<this.columns.length),this.activeColIdx=e,this.hasHeader())for(const t of this.headerElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}null===(t=this.activeNode)||void 0===t||t.update(ChangeType.status);for(const t of this.nodeListElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}this.scrollToHorz()}setActiveNode(e,t=!0,i){var s;null===(s=this.findKey(e))||void 0===s||s.setActive(t,i)}setFocus(e=!0){e?this.element.focus():this.element.blur()}update(e,t,i){if(this._disableUpdateCount)return void this._disableUpdateIgnoreCount++;t instanceof WunderbaumNode||(i=t,t=null);const s=!!getOption(i,"immediate"),n=RenderFlag,r=this.pendingChangeTypes;switch(e){case ChangeType.any:case ChangeType.colStructure:r.add(n.header),r.add(n.clearMarkup),r.add(n.redraw),r.add(n.scroll);break;case ChangeType.resize:r.add(n.header),r.add(n.redraw);break;case ChangeType.structure:r.add(n.redraw);break;case ChangeType.scroll:r.add(n.scroll);break;case ChangeType.row:case ChangeType.data:case ChangeType.status:assert(t,`Option '${e}' requires a node.`),t._rowElem&&t._render({change:e});break;default:error(`Invalid change type '${e}'.`)}if(e===ChangeType.colStructure){const e=this.isGrid();this.element.classList.toggle("wb-grid",e),!e&&this.isCellNav()&&this.setCellNav(!1)}r.size>0&&(s?this._updateViewportImmediately():this._updateViewportThrottled())}setEnabled(e=!0){const t=this.enabled;return this.enabled=!!e,this.element.classList.toggle("wb-disabled",!e),t}isEnabled(){return this.enabled}isGrid(){return this.columns&&this.columns.length>1}isCellNav(){return!!this._cellNavMode}isRowNav(){return!this._cellNavMode}setCellNav(e=!0){var t;const i=this._cellNavMode;this._cellNavMode=!!e,e&&!i&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",e),null===(t=this.activeNode)||void 0===t||t.update(ChangeType.status)}setNavigationOption(e,t=!1){if(this.isGrid()||e===NavModeEnum.row)switch(this.options.navigationModeOption=e,e){case NavModeEnum.cell:this.setCellNav(!0);break;case NavModeEnum.row:this.setCellNav(!1);break;case NavModeEnum.startCell:t&&this.setCellNav(!0);break;case NavModeEnum.startRow:t&&this.setCellNav(!1);break;default:error(`Invalid mode '${e}'.`)}else this.logWarn("Plain trees only support row navigation mode.")}setStatus(e,t){return this.root.setStatus(e,t)}setTypes(e,t=!0){assert(isPlainObject(e)),t?this.types=e:extend(this.types,e);for(const e of Object.values(this.types))e.classes&&(e.classes=toSet(e.classes))}sortChildren(e=nodeTitleSorter,t=!1){this.root.sortChildren(e,t)}toDictArray(e){var t;return null!==(t=this.root.toDict(!0,e).children)&&void 0!==t?t:[]}_updateColumnWidths(){const e=this.element.clientWidth,t=this.columns,i=t[0];let s=0,n=0,r=0,o=!1;if("*"!==i.id)throw new Error(`First column must have id '*': got '${i.id}'.`);this._columnsById={};for(const e of t){this._columnsById[e.id]=e;const t=e.width;if("*"===e.id&&e!==i)throw new Error(`Column id '*' must be defined only once: '${e.title}'.`);if(t&&"*"!==t)if("number"==typeof t)e._weight=t,n+=t;else if("string"==typeof t&&t.endsWith("px")){e._weight=0;const i=parseFloat(t.slice(0,-2));e._widthPx!=i&&(o=!0,e._widthPx=i),r+=i}else error(`Invalid column width: ${t} (expected string ending with 'px' or number, e.g. "<num>px" or <int>).`);else e._weight=1,n+=1}const l=Math.max(0,e-r);let a=0;for(const e of t){let t;if(e._weight){const i=e.minWidth;t="number"==typeof i?i:"string"==typeof i&&i.endsWith("px")?parseFloat(i.slice(0,-2)):4;const s=Math.max(t,l*e._weight/n);e._widthPx!=s&&(o=!0,e._widthPx=s)}e._ofsPx=a,a+=e._widthPx}t[t.length-1]._widthPx-=0,s=a-0;const d=`${s}px`;return this.headerElement.style.width=d,this.listContainerElement.style.width=d,o}_renderHeaderMarkup(){assert(this.headerElement);const e=this.hasHeader();if(setElemDisplay(this.headerElement,e),!e)return;const t=this.columns.length,i=this.headerElement.querySelector(".wb-row");assert(i),i.innerHTML="<span class='wb-col'></span>".repeat(t);for(let e=0;e<t;e++){const s=this.columns[e],n=i.children[e];n.style.left=s._ofsPx+"px",n.style.width=s._widthPx+"px","string"==typeof s.headerClasses?s.headerClasses&&n.classList.add(...s.headerClasses.split(" ")):s.classes&&n.classList.add(...s.classes.split(" "));const r=escapeHtml(s.title||s.id);let o="";s.tooltip&&(o=escapeTooltip(s.tooltip),o=` title="${o}"`);let l="";e<t-1&&(l='<span class="wb-col-resizer"></span>'),n.innerHTML=`<span class="wb-col-title"${o}>${r}</span>${l}`,this.isCellNav()&&n.classList.toggle("wb-active",e===this.activeColIdx)}}updatePendingModifications(){this.pendingChangeTypes.size>0&&this._updateViewportImmediately()}_updateViewportImmediately(){var e;if(this._disableUpdateCount)return this.log(`_updateViewportImmediately() IGNORED (disable level: ${this._disableUpdateCount})`),void this._disableUpdateIgnoreCount++;const t=RenderFlag,i=new Set(this.pendingChangeTypes);this.pendingChangeTypes.clear();if(i.has(t.scroll)&&1===i.size)this._updateRows({newNodesOnly:!0});else{if(this.log("_updateViewportImmediately():",i),!1!==this.options.adjustHeight){let e=this.listContainerElement.clientHeight;const t=this.headerElement.clientHeight,i=this.element.clientHeight-t-1;Math.abs(e-i)>1&&(this.listContainerElement.style.height=i+"px",e=i)}i.has(t.clearMarkup)&&this.visit((e=>{e.removeMarkup()})),i.has(t.header)&&(this._updateColumnWidths(),this._renderHeaderMarkup()),this._updateRows()}if(this.options.connectTopBreadcrumb){let t=null===(e=this.getTopmostVpNode(!0))||void 0===e?void 0:e.getPath(!1,"title"," > ");t=t?t+" >":"",this.options.connectTopBreadcrumb.textContent=t}this._callEvent("update")}_updateRows(e){const t=!!(e=Object.assign({newNodesOnly:!1},e)).newNodesOnly,i=this.element.clientHeight,s=this.element.scrollTop;let n=Math.max(0,s/22-5);n=Math.floor(n),n%2&&n--;let r=Math.max(0,(s+i)/22+5);r=Math.ceil(r);const o=new Set;this.nodeListElement.childNodes.forEach((e=>{const t=e;o.add(t._wb_node)}));let l=0,a=0,d=!1,c="first";this.visitRows((function(e){const i=e._rowElem;e._rowIdx!==l&&(e._rowIdx=l,d=!0),l<n||l>r?i&&(c=i):i&&t?(o.delete(e),i.style.top=22*l+"px",c=i):(o.delete(e),i&&(i.style.top=22*l+"px"),e._render({top:a,after:c}),c=e._rowElem),l++,a+=22})),this.treeRowCount=l;for(const e of o)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=`${a}px`,d}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,o,l,a=0,d=!1===(t=t||{}).includeSelf,c=t.start||this.root.children[0];const h=!!t.includeHidden,u=!h&&"hide"===this.filterMode;for(n=c.parent;n;){for(o=n.children,s=o.indexOf(c)+a,assert(s>=0,`Could not find ${c} in parent's children: ${n}`),i=s;i<o.length;i++){if(c=o[i],c===l)return!1;if(!u||c.statusNodeType||c.match||c.subMatchCount){if(!d&&!1===e(c))return!1;if(d=!1,c.children&&c.children.length&&(h||c.expanded)&&(r=c.visit((t=>t!==l&&(!u||t.match||t.subMatchCount?!1!==e(t)&&(h||!t.children||t.expanded?void 0:"skip"):"skip")),!1),!1===r))return!1}}c=n,n=n.parent,a=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),assert(t.start,"`wrap` option requires `start`"),l=t.start,t.wrap=!1,n=this.root,a=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=t.start||this.root.children[0];const o=!!t.includeHidden;if(!1!==t.includeSelf&&!1===e(r))return!1;for(;;){if(n=r.parent,i=n.children,i[0]===r){if(r=n,!r.parent)break;i=n.children}else for(s=i.indexOf(r),r=i[s-1];(o||r.expanded)&&r.children&&r.children.length;)i=r.children,n=r,r=i[i.length-1];if((o||r.isVisible())&&!1===e(r))return!1}return!0}load(e){return this.clear(),this.root.load(e)}enableUpdate(e){e?(assert(this._disableUpdateCount>0,"enableUpdate(true) was called too often"),this._disableUpdateCount--,0===this._disableUpdateCount&&(this.logDebug(`enableUpdate(): active again. Re-painting to catch up with ${this._disableUpdateIgnoreCount} ignored update requests...`),this._disableUpdateIgnoreCount=0,this.update(ChangeType.any,{immediate:!0}))):this._disableUpdateCount++}filterNodes(e,t){return this.extensions.filter.filterNodes(e,t)}filterBranches(e,t){return this.extensions.filter.filterBranches(e,t)}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}Wunderbaum.sequence=0,Wunderbaum.version="v0.5.4",Wunderbaum.util=util;export{Wunderbaum};
86
86
  //# sourceMappingURL=wunderbaum.esm.min.js.map
@@ -7,7 +7,7 @@
7
7
  /*!
8
8
  * Wunderbaum - util
9
9
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
10
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
10
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
11
11
  */
12
12
  /** @module util */
13
13
  /** Readable names for `MouseEvent.button` */
@@ -771,7 +771,7 @@
771
771
  /*!
772
772
  * Wunderbaum - types
773
773
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
774
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
774
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
775
775
  */
776
776
  /**
777
777
  * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
@@ -835,7 +835,7 @@
835
835
  /*!
836
836
  * Wunderbaum - wb_extension_base
837
837
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
838
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
838
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
839
839
  */
840
840
  class WunderbaumExtension {
841
841
  constructor(tree, id, defaults) {
@@ -1191,7 +1191,7 @@
1191
1191
  /*!
1192
1192
  * Wunderbaum - ext-filter
1193
1193
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1194
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1194
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1195
1195
  */
1196
1196
  const START_MARKER = "\uFFF7";
1197
1197
  const END_MARKER = "\uFFF8";
@@ -1491,7 +1491,7 @@
1491
1491
  /*!
1492
1492
  * Wunderbaum - ext-keynav
1493
1493
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1494
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1494
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1495
1495
  */
1496
1496
  const QUICKSEARCH_DELAY = 500;
1497
1497
  class KeynavExtension extends WunderbaumExtension {
@@ -1837,7 +1837,7 @@
1837
1837
  /*!
1838
1838
  * Wunderbaum - ext-logger
1839
1839
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1840
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1840
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1841
1841
  */
1842
1842
  class LoggerExtension extends WunderbaumExtension {
1843
1843
  constructor(tree) {
@@ -1879,7 +1879,7 @@
1879
1879
  /*!
1880
1880
  * Wunderbaum - common
1881
1881
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1882
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
1882
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
1883
1883
  */
1884
1884
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
1885
1885
  /**
@@ -2145,7 +2145,7 @@
2145
2145
  /*!
2146
2146
  * Wunderbaum - ext-dnd
2147
2147
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2148
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2148
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2149
2149
  */
2150
2150
  const nodeMimeType = "application/x-wunderbaum-node";
2151
2151
  class DndExtension extends WunderbaumExtension {
@@ -2517,7 +2517,7 @@
2517
2517
  /*!
2518
2518
  * Wunderbaum - drag_observer
2519
2519
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2520
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2520
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2521
2521
  */
2522
2522
  /**
2523
2523
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2653,7 +2653,7 @@
2653
2653
  /*!
2654
2654
  * Wunderbaum - ext-grid
2655
2655
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2656
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2656
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2657
2657
  */
2658
2658
  class GridExtension extends WunderbaumExtension {
2659
2659
  constructor(tree) {
@@ -2690,7 +2690,7 @@
2690
2690
  /*!
2691
2691
  * Wunderbaum - deferred
2692
2692
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2693
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2693
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2694
2694
  */
2695
2695
  /**
2696
2696
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -2743,7 +2743,7 @@
2743
2743
  /*!
2744
2744
  * Wunderbaum - wunderbaum_node
2745
2745
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2746
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
2746
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
2747
2747
  */
2748
2748
  /** WunderbaumNode properties that can be passed with source data.
2749
2749
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -5068,7 +5068,7 @@
5068
5068
  /*!
5069
5069
  * Wunderbaum - ext-edit
5070
5070
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
5071
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
5071
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
5072
5072
  */
5073
5073
  // const START_MARKER = "\uFFF7";
5074
5074
  class EditExtension extends WunderbaumExtension {
@@ -5364,8 +5364,8 @@
5364
5364
  * https://github.com/mar10/wunderbaum
5365
5365
  *
5366
5366
  * Released under the MIT license.
5367
- * @version v0.5.3
5368
- * @date Sun, 15 Oct 2023 16:42:56 GMT
5367
+ * @version v0.5.4
5368
+ * @date Sun, 15 Oct 2023 16:43:28 GMT
5369
5369
  */
5370
5370
  // import "./wunderbaum.scss";
5371
5371
  class WbSystemRoot extends WunderbaumNode {
@@ -7497,7 +7497,7 @@
7497
7497
  }
7498
7498
  Wunderbaum.sequence = 0;
7499
7499
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
7500
- Wunderbaum.version = "v0.5.3"; // Set to semver by 'grunt release'
7500
+ Wunderbaum.version = "v0.5.4"; // Set to semver by 'grunt release'
7501
7501
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
7502
7502
  Wunderbaum.util = util;
7503
7503
 
@@ -2,17 +2,17 @@
2
2
  /*!
3
3
  * Wunderbaum - util
4
4
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
5
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
5
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
6
6
  */const t={0:"",1:"left",2:"middle",3:"right",4:"back",5:"forward"},i=function(){const e=navigator;return{isMac:/Mac/.test(e.platform)}}().isMac,s=/[&<>"'/]/g,n=/[<>"'/]/g,r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function o(e,t){if(!e)throw t=t||"Assertion failed.",new Error(t)}function l(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}function a(e){throw new Error(e)}function d(e){return(""+e).replace(s,(function(e){return r[e]}))}function c(e){return(""+e).replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function h(e){return(""+e).replace(n,(function(e){return r[e]}))}function u(e,t=!1){const i=e.tagName;let s=null;if("SPAN"===i&&e.classList.contains("wb-col")){const i=e,n=i.querySelector("input,select");if(n)return u(n,t);i.innerText=""+s}else if("INPUT"===i){const i=e;switch(i.type){case"button":case"reset":case"submit":case"image":break;case"checkbox":s=i.indeterminate?null:i.checked;break;case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":s=t?i.valueAsDate:i.value;break;case"number":case"range":s=i.valueAsNumber;break;case"radio":{const e=i.name,t=i.parentElement.querySelector(`input[name="${e}"]:checked`);s=t?t.value:void 0}break;default:s=i.value}}else if("SELECT"===i){s=e.value}return s}function p(e,t){const i=v(e).style;t?"none"===i.display&&(i.display=""):""===i.display&&(i.display="none")}function f(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstElementChild}const g=new Set(["Alt","Control","Meta","Shift"]);function v(e){return e?"string"==typeof e?document.querySelector(e):e:null}function m(e){return e?"string"==typeof e?document.querySelector(e):e:null}function b(e){const i=e.key,s=e.type,n=[];return e.altKey&&n.push("Alt"),e.ctrlKey&&n.push("Control"),e.metaKey&&n.push("Meta"),e.shiftKey&&n.push("Shift"),"click"===s||"dblclick"===s?n.push(t[e.button]+s):"wheel"===s?n.push(s):g.has(i)||n.push(i),n.join("+")}function y(...e){for(let t=1;t<e.length;t++){const i=e[t];if(null!=i)for(const t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[0][t]=i[t])}return e[0]}function w(e){return Array.isArray(e)}function E(e){return 0===Object.keys(e).length&&e.constructor===Object}function x(e){return"[object Object]"===Object.prototype.toString.call(e)}function _(e,t,i,s){let n,r;e=m(e),s?(n=i,r=s):(n="",r=i),t.split(" ").forEach((t=>{e.addEventListener(t,(function(e){if(!n)return r(e);if(e.target){let t=e.target;if(t.matches(n))return r(e);if(t=t.closest(n),t)return r(e)}}))}))}function C(e,t,i,s){let n,r;const o=s||e,l=e[t],a=(...e)=>l.apply(o,e),d=e=>l.apply(o,e);e[t]=(...e)=>{try{return n=o._super,r=o._superApply,o._super=a,o._superApply=d,i.apply(o,e)}finally{o._super=n,o._superApply=r}}}function k(e,t,i=void 0){let s;e&&t.indexOf(".")>=0&&([s,t]=t.split("."),e=e[s]);const n=e?e[t]:null;return null!=n?n:i}function N(e){if(e instanceof Set)return e;if("string"==typeof e){const t=new Set;for(const i of e.split(" "))t.add(i.trim());return t}if(Array.isArray(e))return new Set(e);throw new Error("Cannot convert to Set<string>: "+e)}function S(e,t){let i=0,s=null;const n=Object.assign({minDelay:16,defaultDelay:200,maxDelay:5e3,delayFactor:2},t),r=Math.max(16,+n.minDelay),o=+n.maxDelay,l=(...t)=>{if(i)s=t,i+=1;else{i=1;const a=t;s=null;const d=Date.now();try{e.apply(this,a)}catch(e){console.error(e)}const c=Date.now()-d,h=Math.min(Math.max(r,c*n.delayFactor),o),u=Math.max(r,h-c);setTimeout((()=>{i=0,null!=s&&l.apply(this,s)}),u)}};return l}var D,L,I,T,M,O=Object.freeze({__proto__:null,Deferred:class{constructor(){this.thens=[],this.catches=[],this.status=""}resolve(e){if(this.status)throw new Error("already settled");this.status="resolved",this.resolvedValue=e,this.thens.forEach((t=>t(e))),this.thens=[]}reject(e){if(this.status)throw new Error("already settled");this.status="rejected",this.rejectedError=e,this.catches.forEach((t=>t(e))),this.catches=[]}then(e){"resolved"===status?e(this.resolvedValue):this.thens.unshift(e)}catch(e){"rejected"===this.status?e(this.rejectedError):this.catches.unshift(e)}promise(){return{then:this.then,catch:this.catch}}},MAX_INT:9007199254740991,MOUSE_BUTTONS:t,adaptiveThrottle:S,assert:o,documentReady:l,documentReadyPromise:function(){return new Promise((e=>{l(e)}))},each:function(e,t){if(null==e)return e;const i=e.length;let s=0;if("number"==typeof i)for(;s<i&&!1!==t.call(e[s],s,e[s]);s++);else for(const i in e)if(!1===t.call(e[s],i,e[i]))break;return e},elemFromHtml:f,elemFromSelector:v,error:a,escapeHtml:d,escapeRegex:c,escapeTooltip:h,eventTargetFromSelector:m,eventToString:b,extend:y,extractHtmlText:function(e){return e.indexOf(">")>=0&&a("Not implemented"),e},getOption:k,getValueFromElem:u,isArray:w,isEmptyObject:E,isFunction:function(e){return"function"==typeof e},isMac:i,isPlainObject:x,noop:function(...e){},onEvent:_,overrideMethod:C,setElemDisplay:p,setTimeoutPromise:function(e,t){return new Promise(((i,s)=>{setTimeout((()=>{try{i(e.apply(this))}catch(e){s(e)}}),t)}))},setValueToElem:function e(t,i){const s=t.tagName;if("SPAN"===s&&t.classList.contains("wb-col")){const s=t,n=s.querySelector("input,select");if(n)return e(n,i);s.innerText=""+i}else if("INPUT"===s){const e=t,s=e.type;switch(s){case"checkbox":e.indeterminate=null===i,e.checked=!!i;break;case"date":case"month":case"time":case"week":case"datetime":case"datetime-local":e.valueAsDate=new Date(i);break;case"number":case"range":null==i?e.value=i:e.valueAsNumber=i;break;case"radio":a(`Not yet implemented: ${s}`);break;case"button":case"reset":case"submit":case"image":break;default:e.value=null!=i?i:""}}else if("SELECT"===s){const e=t;null==i?e.selectedIndex=-1:e.value=i}},sleep:async function(e){return new Promise((t=>setTimeout(t,e)))},toSet:N,toggleCheckbox:function(e,t,i){const s=v(e);if(o("checkbox"===s.type),null!=i||(i=s.classList.contains("wb-tristate")||s.indeterminate),void 0===t){switch(s.indeterminate?null:s.checked){case!0:t=!1;break;case!1:t=!i||null;break;case null:t=!0}}s.indeterminate=null==t,s.checked=!!t},type:function(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()}});
7
7
  /*!
8
8
  * Wunderbaum - types
9
9
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
10
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
10
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
11
11
  */!function(e){e.any="any",e.data="data",e.colStructure="colStructure",e.resize="resize",e.row="row",e.structure="structure",e.status="status",e.scroll="scroll"}(D||(D={})),function(e){e.clearMarkup="clearMarkup",e.header="header",e.redraw="redraw",e.scroll="scroll"}(L||(L={})),function(e){e.ok="ok",e.loading="loading",e.error="error",e.noData="noData",e.paging="paging"}(I||(I={})),function(e){e.unknown="",e.checkbox="checkbox",e.column="column",e.expander="expander",e.icon="icon",e.prefix="prefix",e.title="title"}(T||(T={})),function(e){e.startRow="startRow",e.cell="cell",e.startCell="startCell",e.row="row"}(M||(M={}));
12
12
  /*!
13
13
  * Wunderbaum - wb_extension_base
14
14
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
15
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
15
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
16
16
  */
17
17
  class A{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id=t,this.treeOpts=e.options;const s=e.options;void 0===this.treeOpts[t]?s[t]=this.extensionOpts=y({},i):(this.extensionOpts=y({},i,s[t]),s[t]=this.extensionOpts),this.enabled=this.getPluginOption("enabled",!0)}init(){this.tree.element.classList.add("wb-ext-"+this.id)}getPluginOption(e,t){var i;return null!==(i=this.extensionOpts[e])&&void 0!==i?i:t}setPluginOption(e,t){this.extensionOpts[e]=t}setEnabled(e=!0){return this.setPluginOption("enabled",!!e)}onKeyEvent(e){}onRender(e){}}
18
18
  /*!
@@ -23,53 +23,53 @@ class A{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id=t,this.treeOpts=e
23
23
  /*!
24
24
  * Wunderbaum - ext-filter
25
25
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
26
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
26
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
27
27
  */
28
28
  const q="￷",j="￸",V=new RegExp(c("￷"),"g"),H=new RegExp(c("￸"),"g");class K extends A{constructor(e){super(e,"filter",{connectInput:null,autoApply:!0,autoExpand:!1,counter:!0,fuzzy:!1,hideExpandedCounter:!0,hideExpanders:!1,highlight:!0,leavesOnly:!1,mode:"dim",noData:!0}),this.lastFilterArgs=null}init(){super.init();const e=this.getPluginOption("connectInput");e&&(this.queryInput=v(e),_(this.queryInput,"input",U((e=>{this.filterNodes(this.queryInput.value.trim(),{})}),700)))}setPluginOption(e,t){if(super.setPluginOption(e,t),"mode"===e)this.tree.filterMode="hide"===t?"hide":"dim",this.tree.updateFilter()}_applyFilterNoUpdate(e,t,i){return this.tree.runWithDeferredUpdate((()=>this._applyFilterImpl(e,t,i)))}_applyFilterImpl(e,t,i){let s,n,r=0;const o=Date.now(),l=this.tree,a=l.options,h=a.autoCollapse,u=y({},a.filter,i),p="hide"===u.mode,f=!!u.leavesOnly&&!t;if("string"==typeof e){if(""===e)return l.logInfo("Passing an empty string as a filter is handled as clearFilter()."),void this.clearFilter();s=u.fuzzy?e.split("").map(c).reduce((function(e,t){return e+"([^"+t+"]*)"+t}),""):c(e);const t=new RegExp(s,"i"),i=new RegExp(c(e),"gi");e=e=>{if(!e.title)return!1;const s=e.title,r=s.match(t);return r&&u.highlight&&(n=u.fuzzy?function(e,t,i=!0){const s=[];for(let e=1;e<t.length;e++){const i=t[e].length+(1===e?0:1)+(s[s.length-1]||0);s.push(i)}const n=e.split("");i?s.forEach((function(e){n[e]=q+n[e]+j})):s.forEach((function(e){n[e]="<mark>"+n[e]+"</mark>"}));return n.join("")}
29
29
  /*!
30
30
  * Wunderbaum - ext-keynav
31
31
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
32
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
32
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
33
33
  */(s,r,!0):s.replace(i,(function(e){return q+e+j})),e.titleWithHighlight=d(n).replace(V,"<mark>").replace(H,"</mark>")),!!r}}return l.filterMode=u.mode,this.lastFilterArgs=arguments,l.element.classList.toggle("wb-ext-filter-hide",!!p),l.element.classList.toggle("wb-ext-filter-dim",!p),l.element.classList.toggle("wb-ext-filter-hide-expanders",!!u.hideExpanders),l.root.subMatchCount=0,l.visit((e=>{delete e.match,delete e.titleWithHighlight,e.subMatchCount=0})),l.setStatus(I.ok),a.autoCollapse=!1,l.visit((i=>{if(f&&null!=i.children)return;let s=e(i);if("skip"===s)return i.visit((function(e){e.match=!1}),!0),"skip";let n=!1;(t||"branch"===s)&&i.parent.match&&(s=!0,n=!0),s&&(r++,i.match=!0,i.visitParents((e=>{e!==i&&(e.subMatchCount+=1),!u.autoExpand||n||e.expanded||(e.setExpanded(!0,{noAnimation:!0,noEvents:!0}),e._filterAutoExpanded=!0)}),!0))})),a.autoCollapse=h,0===r&&u.noData&&p&&l.root.setStatus(I.noData),l.logInfo(`Filter '${s}' found ${r} nodes in ${Date.now()-o} ms.`),r}filterNodes(e,t){return this._applyFilterNoUpdate(e,!1,t)}filterBranches(e,t){return this._applyFilterNoUpdate(e,!0,t)}updateFilter(){var e;const t=this.tree;t.filterMode&&this.lastFilterArgs&&(null===(e=t.options.filter)||void 0===e?void 0:e.autoApply)?this._applyFilterNoUpdate.apply(this,this.lastFilterArgs):t.logWarn("updateFilter(): no filter active.")}clearFilter(){const e=this.tree;e.enableUpdate(!1),e.setStatus(I.ok),delete e.root.match,delete e.root.subMatchCount,e.visit((e=>{delete e.match,delete e.subMatchCount,delete e.titleWithHighlight,e._filterAutoExpanded&&e.expanded&&e.setExpanded(!1,{noAnimation:!0,noEvents:!0}),delete e._filterAutoExpanded})),e.filterMode=null,this.lastFilterArgs=null,e.element.classList.remove("wb-ext-filter-dim","wb-ext-filter-hide"),e.enableUpdate(!0)}}class W extends A{constructor(e){super(e,"keynav",{})}_getEmbeddedInputElem(e){var t;let i=null;if(e&&null!=e.type)i=e;else{const e=null===(t=this.tree.getActiveColElem())||void 0===t?void 0:t.querySelector("input,select");e&&(i=e)}return i}_isCurInputFocused(){var e;return!!(null===(e=this.tree.getActiveColElem())||void 0===e?void 0:e.querySelector("input:focus,select:focus"))}onKeyEvent(e){const t=e.event,i=this.tree,s=e.options,n=!t.ctrlKey||s.autoActivate,r=this._getEmbeddedInputElem(t.target),o=r&&this._isCurInputFocused(),l=s.navigationModeOption;let a,d=b(t),c=e.node,h=!0;if(!i.isEnabled())return!1;if(!1===i._callEvent("keydown",e))return!1;if(!1===i._callMethod("edit._preprocessKeyEvent",e))return!1;if(!c){const e=i.getFocusNode()||i.getActiveNode(),t=i.getFirstChild();if(!e&&t&&"ArrowDown"===d)return t.logInfo("Keydown: activate first node."),void t.setActive();a=e||t,a&&(a.setFocus(),c=i.getFocusNode(),c.logInfo("Keydown: force focus on active node."))}const u=c.isColspan();if(i.isRowNav()){if(o){switch(d){case"Enter":r.blur(),i.setFocus();break;case"Escape":c._render(),i.setFocus()}return}if(s.quicksearch&&1===d.length&&/^\w$/.test(d)&&!r){const e=Date.now();e-i.lastQuicksearchTime>500&&(i.lastQuicksearchTerm=""),i.lastQuicksearchTime=e,i.lastQuicksearchTerm+=d;const s=i.findNextNode(i.lastQuicksearchTerm,i.getActiveNode());return s&&s.setActive(!0,{event:t}),void t.preventDefault()}switch(d){case"Enter":c.isActive()&&(c.isExpanded()?d="Subtract":c.isExpandable(!0)&&(d="Add"));break;case"ArrowLeft":c.expanded&&(d="Subtract");break;case"ArrowRight":if(!c.expanded&&c.isExpandable(!0))d="Add";else if(l===M.startCell||l===M.startRow)return t.preventDefault(),i.setCellNav(),!1}switch(d){case"+":case"Add":c.setExpanded(!0);break;case"-":case"Subtract":c.setExpanded(!1);break;case" ":c.getOption("checkbox")?c.toggleSelected():c.setActive(!0,{event:t});break;case"Enter":c.setActive(!0,{event:t});break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":c.navigate(d,{activate:n,event:t});break;default:h=!1}}else{const e=this._getEmbeddedInputElem(null),s=e?e.type||e.tagName:"",r=e&&this._isCurInputFocused(),o=e&&"checkbox"!==s;if(r){if("Escape"===d)return c._render(),c.logDebug("Reset focused input"),i.setFocus(),void i.setColumn(i.activeColIdx);if("Enter"!==d)return void c.logDebug(`Ignored ${d} inside focused input`)}else if(e&&1===d.length&&o)return e.focus(),e.value="",c.logDebug(`Focus imput: ${d}`),!1;switch("Tab"===d?(d="ArrowRight",h=!0):"Shift+Tab"===d&&(d=i.activeColIdx>0?"ArrowLeft":"",h=!0),d){case"+":case"Add":c.setExpanded(!0);break;case"-":case"Subtract":c.setExpanded(!1);break;case" ":0===i.activeColIdx&&c.getOption("checkbox")?(c.toggleSelected(),h=!0):e&&"checkbox"===s&&(e.click(),h=!0);break;case"F2":e&&!r&&o&&(e.focus(),h=!0);break;case"Enter":i.setFocus(),(0===i.activeColIdx||u)&&c.isExpandable()?(c.setExpanded(!c.isExpanded()),h=!0):e&&!r&&o&&(e.focus(),h=!0);break;case"Escape":i.setFocus(),c.log("keynav: focus tree..."),i.isCellNav()&&l!==M.cell&&(c.log("keynav: setCellNav(false)"),i.setCellNav(!1),i.setFocus(),h=!0);break;case"ArrowLeft":i.setFocus(),u&&c.isExpanded()?c.setExpanded(!1):!u&&i.activeColIdx>0?i.setColumn(i.activeColIdx-1):l!==M.cell&&i.setCellNav(!1),h=!0;break;case"ArrowRight":i.setFocus(),u&&!c.isExpanded()?c.setExpanded():!u&&i.activeColIdx<i.columns.length-1&&i.setColumn(i.activeColIdx+1),h=!0;break;case"Home":i.setFocus(),!u&&i.activeColIdx>0&&i.setColumn(0),h=!0;break;case"End":i.setFocus(),!u&&i.activeColIdx<i.columns.length-1&&i.setColumn(i.columns.length-1),h=!0;break;case"ArrowDown":case"ArrowUp":case"Backspace":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":c.navigate(d,{activate:n,event:t}),h=!0;break;default:h=!1}}h&&t.preventDefault()}}
34
34
  /*!
35
35
  * Wunderbaum - ext-logger
36
36
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
37
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
37
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
38
38
  */class B extends A{constructor(e){super(e,"logger",{}),this.ignoreEvents=new Set(["iconBadge","render","discard"]),this.prefix=e+".ext-logger"}init(){const e=this.tree;if(e.getOption("debugLevel")>=4){const t=this.ignoreEvents,i=this.prefix;C(e,"callEvent",(function(s,n){if(t.has(s))return e._superApply(arguments);const r=Date.now(),o=e._superApply(arguments);return e.logDebug(`${i}: callEvent('${s}') took ${Date.now()-r} ms.`,arguments[1]),o}))}}onKeyEvent(e){this.tree.logDebug(`${this.prefix}: onKeyEvent()`,e)}}
39
39
  /*!
40
40
  * Wunderbaum - common
41
41
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
42
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
42
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
43
43
  */const G=22,Q=new RegExp(/\.|\//),Y={bootstrap:{error:"bi bi-exclamation-triangle",loading:"bi bi-chevron-right wb-busy",noData:"bi bi-question-circle",expanderExpanded:"bi bi-chevron-down",expanderCollapsed:"bi bi-chevron-right",expanderLazy:"bi bi-chevron-right wb-helper-lazy-expander",checkChecked:"bi bi-check-square",checkUnchecked:"bi bi-square",checkUnknown:"bi bi-dash-square-dotted",radioChecked:"bi bi-circle-fill",radioUnchecked:"bi bi-circle",radioUnknown:"bi bi-record-circle",folder:"bi bi-folder2",folderOpen:"bi bi-folder2-open",folderLazy:"bi bi-folder-symlink",doc:"bi bi-file-earmark"},fontawesome6:{error:"fa-solid fa-triangle-exclamation",loading:"fa-solid fa-chevron-right fa-beat",noData:"fa-solid fa-circle-question",expanderExpanded:"fa-solid fa-chevron-down",expanderCollapsed:"fa-solid fa-chevron-right",expanderLazy:"fa-solid fa-chevron-right wb-helper-lazy-expander",checkChecked:"fa-regular fa-square-check",checkUnchecked:"fa-regular fa-square",checkUnknown:"fa-regular fa-square-minus",radioChecked:"fa-solid fa-circle",radioUnchecked:"fa-regular fa-circle",radioUnknown:"fa-regular fa-circle-question",folder:"fa-solid fa-folder-closed",folderOpen:"fa-regular fa-folder-open",folderLazy:"fa-solid fa-folder-plus",doc:"fa-regular fa-file"}},X=new Set(["_format","_keyMap","_positional","_typeList","_version","children","columns","types"]),J={" ":"toggleSelect","+":"expand",Add:"expand",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"parent","/":"collapseAll",Divide:"collapseAll",End:"lastCol",Home:"firstCol","Control+End":"last","Control+Home":"first","Meta+ArrowDown":"last","Meta+ArrowUp":"first","*":"expandAll",Multiply:"expandAll",PageDown:"pageDown",PageUp:"pageUp","-":"collapse",Subtract:"collapse"};function Z(e){return e instanceof RegExp?function(t){return e.test(t.title)}:(o("string"==typeof e),function(t){return t.title===e})}function ee(e,t){const i=e.title.toLowerCase(),s=t.title.toLowerCase();return i===s?0:i>s?1:-1}function te(e){const{_format:t,_keyMap:i,_typeList:s}=e;"flat"===t&&function(e){var t,i,s;const{_format:n,_keyMap:r,_positional:o,children:l}=e;if("flat"!==n)throw new Error(`Expected source._format: "flat", but got ${n}`);if(o&&o.includes("children"))throw new Error(`source._positional must not include "children": ${o}`);const a={};if(r)for(const[e,t]of Object.entries(r))a[t]=e;const d=o.map((e=>a[e])),c=[],h={},u={},p=null!==(t=a.key)&&void 0!==t?t:"key",f=null!==(i=a.children)&&void 0!==i?i:"children";for(const[e,t]of l.entries()){const[i,n,r={}]=t;t[1]=null,null!=t[2]&&(t[2]=null),n.forEach(((e,t)=>{r[d[t]]=e})),u[e]=r;const o=r[p];null!=o&&(h[o]=r);let l=null;if(null===i);else if("number"==typeof i){if(l=u[i],void 0===l)throw new Error(`unflattenSource: Could not find parent node by index: ${i}.`)}else if(l=h[i],void 0===l)throw new Error(`unflattenSource: Could not find parent node by key: ${i}`);l?(null!==(s=l[f])&&void 0!==s||(l[f]=[]),l[f].push(r)):c.push(r)}delete e.children,e.children=c}(e),delete e._format,delete e._version,delete e._keyMap,delete e._typeList,delete e._positional,function e(t){for(const n of t){i&&Object.getOwnPropertyNames(n).forEach((e=>{var t;const s=null!==(t=i[e])&&void 0!==t?t:e;s!==e&&(n[s]=n[e],delete n[e])}));const t=n.type;if(s&&null!=t&&"number"==typeof t){const e=s[t];if(null==e)throw new Error(`Expected typeList[${t}] entry in [${s}]`);n.type=e}n.children&&e(n.children)}}(e.children)}
44
44
  /*!
45
45
  * Wunderbaum - ext-dnd
46
46
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
47
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
47
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
48
48
  */const ie="application/x-wunderbaum-node";class se extends A{constructor(e){super(e,"dnd",{autoExpandMS:1500,multiSource:!1,effectAllowed:"all",dropEffectDefault:"move",preventForeignNodes:!1,preventLazyParents:!0,preventNonNodes:!1,preventRecursion:!0,preventSameParent:!1,preventVoidMoves:!0,serializeClipboardData:!0,scroll:!0,scrollSensitivity:20,scrollSpeed:5,sourceCopyHook:null,dragStart:null,drag:null,dragEnd:null,dragEnter:null,dragOver:null,dragExpand:null,drop:null,dragLeave:null}),this.srcNode=null,this.lastTargetNode=null,this.lastEnterStamp=0,this.lastAllowedDropRegions=null,this.lastDropEffect=null,this.lastDropRegion=!1,this.currentScrollDir=0,this.applyScrollDirThrottled=function(e,t=0,i={}){let s=!0,n=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return z(i)&&(s="leading"in i?!!i.leading:s,n="trailing"in i?!!i.trailing:n),U(e,t,{leading:s,trailing:n,maxWait:t})}(this.applyScrollDir,50)}init(){super.init();const e=this.tree,t=e.options.dnd;t.dragStart&&_(e.element,"dragstart drag dragend",this.onDragEvent.bind(this)),t.dragEnter&&_(e.element,"dragenter dragover dragleave drop",this.onDropEvent.bind(this))}_leaveNode(){const e=this.lastTargetNode;this.lastEnterStamp=0,e&&(e.setClass("wb-drop-target wb-drop-over wb-drop-after wb-drop-before",!1),this.lastTargetNode=null)}unifyDragover(e){if(!1===e)return!1;if(e instanceof Set)return e.size>0&&e;if(!0===e)return new Set(["over","before","after"]);if("string"==typeof e||w(e))return(e=N(e)).size>0&&e;throw new Error("Unsupported drop region definition: "+e)}_calcDropRegion(e,t){const i=e.offsetY;return!!t&&(3===t.size?i<5.5?"before":i>16.5?"after":"over":1===t.size&&t.has("over")?"over":i>11?"after":"before")}applyScrollDir(){if(this.isDragging()&&this.currentScrollDir){const e=this.tree.options.dnd,t=this.tree.element,i=t.scrollTop;this.currentScrollDir<0?t.scrollTop=Math.max(0,i-e.scrollSpeed):this.currentScrollDir>0&&(t.scrollTop=i+e.scrollSpeed)}}autoScroll(e){const t=this.tree,i=t.options.dnd.scrollSensitivity,s=t.element,n=t.headerElement.clientHeight,r=s.offsetHeight,o=s.scrollTop;return this.currentScrollDir=0,o>0&&e>0&&e<=i+n?this.currentScrollDir=-1:o<s.scrollHeight-r&&e>=r-i&&(this.currentScrollDir=1),this.currentScrollDir&&this.applyScrollDirThrottled(),s.scrollTop-o}isDragging(){return!!this.srcNode}onDragEvent(e){const t=this.treeOpts.dnd,i=ue.getNode(e);if(i){if("drag"!==e.type&&this.tree.logDebug("onDragEvent."+e.type+", srcNode: "+i,e),"dragstart"===e.type){if(e.dataTransfer.effectAllowed=t.effectAllowed,i.isEditing())return i.logDebug("Prevented dragging node in edit mode."),e.preventDefault(),!1;if(!i._callEvent("dnd.dragStart",{event:e}))return e.preventDefault(),!1;const s=i.toDict(!0,(e=>{e._org_key=e.key,delete e.key}));s._treeId=i.tree.id,t.serializeClipboardData&&("function"==typeof t.serializeClipboardData?e.dataTransfer.setData(ie,t.serializeClipboardData(s)):e.dataTransfer.setData(ie,JSON.stringify(s))),e.dataTransfer.setData("text/plain",i.title),this.srcNode=i,setTimeout((()=>{i.setClass("wb-drag-source")}),0)}else"drag"===e.type?t.drag&&i._callEvent("dnd.drag",{event:e}):"dragend"===e.type&&(i.setClass("wb-drag-source",!1),this.srcNode=null,this.lastTargetNode&&this._leaveNode(),t.dragEnd&&i._callEvent("dnd.dragEnd",{event:e}));return!0}}_isVoidDrop(e,t,i){return this.tree.logDebug(`_isVoidDrop: ${t} -> ${i} ${e}`),!(!this.treeOpts.dnd.preventVoidMoves||!t)&&("before"===i&&e===t.getNextSibling()||"after"===i&&e===t.getPrevSibling()?(this.tree.logDebug("Prevented before/after self"),!0):t===e||t.parent===e)}onDropEvent(e){const t=this.srcNode,i=t?t.tree:null,s=ue.getNode(e),n=this.treeOpts.dnd,r=e.dataTransfer,o=this._calcDropRegion(e,this.lastAllowedDropRegions);if(s){if(["dragenter","dragover","dragleave"].includes(e.type)||this.tree.logDebug("onDropEvent."+e.type+" targetNode: "+s+", ea: "+(null==r?void 0:r.effectAllowed)+", de: "+(null==r?void 0:r.dropEffect),", cy: "+e.offsetY,", r: "+o,", srcNode: "+t,e),"dragenter"===e.type){if(this.lastAllowedDropRegions=null,this.lastTargetNode&&this.lastTargetNode!==s&&this._leaveNode(),this.lastTargetNode=s,this.lastEnterStamp=Date.now(),s.isStatusNode()||n.preventForeignNodes&&s.tree!==i||n.preventLazyParents&&!s.isLoaded()||n.preventNonNodes&&!t||n.preventRecursion&&(null==t?void 0:t.isAncestorOf(s))||n.preventSameParent&&t&&s.parent===t.parent||n.preventVoidMoves&&s===t)return r.dropEffect="none",this.tree.log("Prevented drop operation"),!0;let o=s._callEvent("dnd.dragEnter",{event:e});return o=this.unifyDragover(o),o?(this.lastAllowedDropRegions=o,this.lastDropEffect=r.dropEffect,s.setClass("wb-drop-target"),e.preventDefault(),!1):(r.dropEffect="none",!0)}if("dragover"===e.type){const i=e.clientY-this.tree.element.offsetTop;this.autoScroll(i),n.dragOver&&s._callEvent("dnd.dragOver",{event:e});const r=this._calcDropRegion(e,this.lastAllowedDropRegions);if(this.lastDropRegion=r,n.autoExpandMS>0&&s.isExpandable(!0)&&!s._isLoading&&Date.now()-this.lastEnterStamp>n.autoExpandMS&&!1!==s._callEvent("dnd.dragExpand",{event:e})&&s.setExpanded(),!r||this._isVoidDrop(s,t,r))return;return s.setClass("wb-drop-over","over"===r),s.setClass("wb-drop-before","before"===r),s.setClass("wb-drop-after","after"===r),e.preventDefault(),!1}if("dragleave"===e.type)n.dragLeave&&s._callEvent("dnd.dragLeave",{event:e});else if("drop"===e.type){e.stopPropagation(),this._leaveNode();const t=this.lastDropRegion;s._callEvent("dnd.drop",{event:e,region:t,defaultDropMode:"over"===t?"appendChild":t,sourceNode:this.srcNode})}}else this._leaveNode()}}
49
49
  /*!
50
50
  * Wunderbaum - drag_observer
51
51
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
52
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
52
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
53
53
  */class ne{constructor(e){if(this.start={x:0,y:0,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},this.dragElem=null,this.dragging=!1,this.events=["mousedown","mouseup","mousemove","keydown"],!e.root)throw new Error("Missing `root` option.");this.opts=Object.assign({thresh:5},e),this.root=e.root,this._handler=this.handleEvent.bind(this),this.events.forEach((e=>{this.root.addEventListener(e,this._handler)}))}disconnect(){this.events.forEach((e=>{this.root.removeEventListener(e,this._handler)}))}getDragElem(){return this.dragElem}isDragging(){return this.dragging}stopDrag(e){this.dragging&&this.opts.dragstop&&e&&(e.type="dragstop",this.opts.dragstop(e)),this.dragElem=null,this.dragging=!1}handleEvent(e){const t=e.type,i=this.opts,s={type:e.type,event:e,dragElem:this.dragElem,dx:e.pageX-this.start.x,dy:e.pageY-this.start.y,apply:void 0};switch(t){case"keydown":this.stopDrag(s);break;case"mousedown":if(this.dragElem){this.stopDrag(s);break}if(i.selector){let t=e.target;if(t.matches(i.selector))this.dragElem=t;else{if(t=t.closest(i.selector),!t)break;this.dragElem=t}}this.start.x=e.pageX,this.start.y=e.pageY,this.start.altKey=e.altKey,this.start.ctrlKey=e.ctrlKey,this.start.metaKey=e.metaKey,this.start.shiftKey=e.shiftKey;break;case"mousemove":if(!this.dragElem)break;if(!this.dragging){if(i.thresh){if(s.dx*s.dx+s.dy*s.dy<i.thresh*i.thresh)break}if(s.type="dragstart",!1===i.dragstart(s)){this.stopDrag(s);break}this.dragging=!0}this.dragging&&this.opts.drag&&(s.type="drag",this.opts.drag(s));break;case"mouseup":if(!this.dragging){this.stopDrag(s);break}0===e.button?s.apply=!0:s.apply=!1,this.stopDrag(s)}}}
54
54
  /*!
55
55
  * Wunderbaum - ext-grid
56
56
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
57
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
57
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
58
58
  */class re extends A{constructor(e){super(e,"grid",{}),this.observer=new ne({root:window.document,selector:"span.wb-col-resizer",thresh:4,dragstart:e=>this.tree.element.contains(e.dragElem),drag:e=>this.handleDrag(e),dragstop:e=>this.handleDrag(e)})}init(){super.init()}handleDrag(e){const t=ue.getEventInfo(e.event);this.tree.log(`${e.type}(${e.dx})`,e,t)}}
59
59
  /*!
60
60
  * Wunderbaum - deferred
61
61
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
62
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
62
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
63
63
  */class oe{constructor(){this._promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){this._resolve(e)}reject(e){this._reject(e)}promise(){return this._promise}then(e){return this._promise.then(e)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}}
64
64
  /*!
65
65
  * Wunderbaum - wunderbaum_node
66
66
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
67
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
67
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
68
68
  */const le=new Set(["checkbox","classes","expanded","icon","iconTooltip","key","lazy","_partsel","radiogroup","refKey","selected","statusNodeType","title","tooltip","type","unselectable"]),ae=new Set(le);ae.delete("_partsel"),ae.delete("unselectable");class de{constructor(e,t,i){var s,n;this.refKey=void 0,this.children=null,this.classes=null,this.data={},this._isLoading=!1,this._requestId=0,this._errorInfo=null,this._partsel=!1,this._partload=!1,this.subMatchCount=0,this._rowIdx=0,this._rowElem=void 0,o(!t||t.tree===e),o(!i.children),this.tree=e,this.parent=t,this.key=""+(null!==(s=i.key)&&void 0!==s?s:++de.sequence),this.title=""+(null!==(n=i.title)&&void 0!==n?n:"<"+this.key+">"),null!=i.refKey&&(this.refKey=""+i.refKey),null!=i.type&&(this.type=""+i.type),this.expanded=!0===i.expanded,null!=i.icon&&(this.icon=i.icon),this.lazy=!0===i.lazy,null!=i.statusNodeType&&(this.statusNodeType=""+i.statusNodeType),null!=i.colspan&&(this.colspan=!!i.colspan),null!=i.checkbox&&(this.checkbox=!!i.checkbox),null!=i.radiogroup&&(this.radiogroup=!!i.radiogroup),this.selected=!0===i.selected,!0===i.unselectable&&(this.unselectable=!0),i.classes&&this.setClass(i.classes);for(const[e,t]of Object.entries(i))le.has(e)||(this.data[e]=t);t&&!this.statusNodeType&&e._registerNode(this)}toString(){return`WunderbaumNode@${this.key}<'${this.title}'>`}*[Symbol.iterator](){const e=this.children;if(e)for(let t=0,i=e.length;t<i;t++){const i=e[t];yield i,i.children&&(yield*i)}}_callEvent(e,t){return this.tree._callEvent(e,y({node:this,typeInfo:this.type?this.tree.types[this.type]:{}},t))}addChildren(e,t){const i=this.tree;let{before:s=null,applyMinExpanLevel:n=!0,_level:r}=null!=t?t:{};null!=r||(r=this.getLevel());const l=[];try{i.enableUpdate(!1),x(e)&&(e=[e]);const t=n&&r<i.options.minExpandLevel;for(const s of e){const e=s.children;delete s.children;const n=new de(i,this,s);t&&!n.isUnloaded()&&(n.expanded=!0),l.push(n),e&&n.addChildren(e,{_level:r+1})}if(this.children)if(null==s||0===this.children.length)this.children=this.children.concat(l);else{s=this.findDirectChild(s);const e=this.children.indexOf(s);o(e>=0,`options.before must be a direct child of ${this}`),this.children.splice(e,0,...l)}else this.children=l;i.update(D.structure)}finally{i.enableUpdate(!0)}return l[0]}addNode(e,t="appendChild"){switch("over"===t&&(t="appendChild"),t){case"after":return this.parent.addChildren(e,{before:this.getNextSibling()});case"before":return this.parent.addChildren(e,{before:this});case"prependChild":return this.addChildren(e,{before:0});case"appendChild":return this.addChildren(e)}o(!1,"Invalid mode: "+t)}applyCommand(e,t){return this.tree.applyCommand(e,this,t)}collapseSiblings(e){for(const t of this.parent.children)t!==this&&t.expanded&&t.setExpanded(!1,e)}setClass(e,t=!0){const i=N(e);if(t)null===this.classes&&(this.classes=new Set),i.forEach((e=>{var i;this.classes.add(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)}));else{if(null===this.classes)return;i.forEach((e=>{var i;this.classes.delete(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)})),0===this.classes.size&&(this.classes=null)}}async expandAll(e=!0,t){const i=this.tree,s=this.tree.options.minExpandLevel,{depth:n=99,loadLazy:r,force:o,keepActiveNodeVisible:l=!0}=null!=t?t:{},a={scrollIntoView:!1,force:o,loadLazy:r};const d=i.logTime(`${this}.expandAll(${e})`);try{i.enableUpdate(!1),await async function t(i,n){var l;if(0===n)return;const d=null==n?null:n-1,c=[];return null===(l=i.children)||void 0===l||l.forEach((i=>{if(e)if(!i.expanded&&(i.children||r&&i.lazy)){const e=i.setExpanded(!0,a);c.push(e),e.then((async()=>{await t(i,d)}))}else c.push(t(i,d));else(!s||o||i.getLevel()>s)&&i.setExpanded(!1,a),t(i,d)})),new Promise((e=>{Promise.all(c).then((()=>{e(!0)}))}))}(this,n)}finally{i.enableUpdate(!0),i.logTimeEnd(d)}i.activeNode&&l&&i.activeNode.scrollIntoView()}findAll(e){const t="function"==typeof e?e:Z(e),i=[];return this.visit((e=>{t(e)&&i.push(e)})),i}findDirectChild(e){const t=this.children;if(!t)return null;if("string"==typeof e){for(let i=0,s=t.length;i<s;i++)if(t[i].key===e)return t[i]}else{if("number"==typeof e)return t[e];if(e.parent===this)return e}return null}findFirst(e){const t="function"==typeof e?e:Z(e);let i=null;return this.visit((e=>{if(t(e))return i=e,!1})),i}findRelatedNode(e,t=!1){return this.tree.findRelatedNode(this,e,t)}*format_iter(e,t){function i(e){const t=e.parent.children;return e===t[t.length-1]}null!=t||(t=[" "," | "," ╰─ "," ├─ "]),null!=e||(e=e=>""+e);const s=s=>{const n=[e(s)];n.unshift(t[i(s)?2:3]);let r=s.parent;for(;r&&r!==this;)n.unshift(t[i(r)?0:1]),r=r.parent;return n.join("")};yield e(this);for(const e of this)yield s(e)}format(e,t){const i=[];for(const s of this.format_iter(e,t))i.push(s);return i.join("\n")}getColElem(e){var t;"string"==typeof e&&(e=this.tree.columns.findIndex((t=>t.id===e)));const i=null===(t=this._rowElem)||void 0===t?void 0:t.querySelectorAll("span.wb-col");return i?i[e]:null}getFirstChild(){return this.children?this.children[0]:null}getLastChild(){return this.children?this.children[this.children.length-1]:null}getLevel(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}getNextSibling(){const e=this.parent.children,t=e.indexOf(this);return e[t+1]||null}getParent(){return this.parent}getParentList(e=!1,t=!1){const i=[];let s=t?this:this.parent;for(;s;)(e||s.parent)&&i.unshift(s),s=s.parent;return i}getPath(e=!0,t="title",i="/"){let s;const n=[],r="function"==typeof t;return this.visitParents((e=>{e.parent&&(s=r?t(e):e[t],n.unshift(s))}),e),n.join(i)}getPrevSibling(){const e=this.parent.children,t=e.indexOf(this);return e[t-1]||null}hasChildren(){if(this.lazy){if(null==this.children)return;if(0===this.children.length)return!1;if(1===this.children.length&&this.children[0].isStatusNode())return;return!0}return!(!this.children||!this.children.length)}hasClass(e){return!!this.classes&&this.classes.has(e)}isActive(){return this.tree.activeNode===this}isAncestorOf(e){return e&&e.isDescendantOf(this)}isChildOf(e){return e&&this.parent===e}isColspan(){return!!this.getOption("colspan")}isDescendantOf(e){if(!e||e.tree!==this.tree)return!1;let t=this.parent;for(;t;){if(t===e)return!0;t===t.parent&&a(`Recursive parent link: ${t}`),t=t.parent}return!1}isExpandable(e=!1){return!(e&&this.expanded||!1===this.children)&&(null==this.children?!!this.lazy:0!==this.children.length||!!this.tree.options.emptyChildListExpandable)}isEditing(){return this.tree._callMethod("edit.isEditingTitle",this)}isExpanded(){return!!this.expanded}isFirstSibling(){const e=this.parent;return!e||e.children[0]===this}isLastSibling(){const e=this.parent;return!e||e.children[e.children.length-1]===this}isLazy(){return!!this.lazy}isLoaded(){return!this.lazy||void 0!==this.hasChildren()}isLoading(){return this._isLoading}isPagingNode(){return"paging"===this.statusNodeType}isParentOf(e){return e&&e.parent===this}isPartload(){return!!this._partload}isPartsel(){return!this.selected&&!!this._partsel}isRadio(){return!!this.parent.radiogroup||"radio"===this.getOption("checkbox")}isRendered(){return!!this._rowElem}isRootNode(){return this.tree.root===this}isSelected(){return!!this.selected||!!this._partsel&&void 0}isStatusNode(){return!!this.statusNodeType}isTopLevel(){return this.tree.root===this.parent}isUnloaded(){return void 0===this.hasChildren()}isVisible(){const e="hide"===this.tree.filterMode,t=this.getParentList(!1,!1);if(e&&!this.match&&!this.subMatchCount)return!1;for(let e=0,i=t.length;e<i;e++){if(!t[e].expanded)return!1}return!0}_loadSourceObject(e,t){var i;const s=this.tree;null!=t||(t=this.getLevel());const n=this._callEvent("receive",{response:e});null!=n&&(e=n),w(e)&&(e={children:e}),o(x(e));const r=null!==(i=e.format)&&void 0!==i?i:"nested";o("nested"===r||"flat"===r),te(e),o(e.children,"If `source` is an object, it must have a `children` property"),e.types&&(s.logInfo("Redefine types",e.columns),s.setTypes(e.types,!1),delete e.types),e.columns&&(s.logInfo("Redefine columns",e.columns),s.columns=e.columns,delete e.columns,s.update(D.colStructure)),this.addChildren(e.children);for(const[t,i]of Object.entries(e))X.has(t)||(s.data[t]=i);"hier"===s.options.selectMode&&this.fixSelection3FromEndNodes(),this._callEvent("load")}async _fetchWithOptions(e){var t,i;let s,n,r,l,d,c={};"string"==typeof e?(s=e,c.method="GET"):x(e)?(({url:s,params:n,body:r,options:l,...d}=e),o(!d||0===Object.keys(d).length,`Unexpected source properties: ${Object.keys(d)}. Use 'options' instead.`),o("string"==typeof s,"expected source.url as string"),x(l)&&(c=l),x(r)&&(o(!c.body,"options.body should be passed as source.body"),c.body=JSON.stringify(c.body),null!==(t=c.method)&&void 0!==t||(c.method="POST")),x(n)&&(s+="?"+new URLSearchParams(n),null!==(i=c.method)&&void 0!==i||(c.method="GET"))):(s="",a(`Unsupported source format: ${e}`)),this.setStatus(I.loading);const h=await fetch(s,c);return h.ok||a(`GET ${s} returned ${h.status}, ${h}`),await h.json()}async load(e){const t=this.tree,i=Date.now(),s=this.parent,n=Date.now();let r=0,o=0,l=0;this._requestId&&this.logWarn(`Recursive load request #${i} while #${this._requestId} is pending.`),this._requestId=i;try{if("string"==typeof e?e:e.url){const t=await this._fetchWithOptions(e);if(o=Date.now()-n,this._requestId&&this._requestId>i)return void this.logWarn(`Ignored load response #${i} because #${this._requestId} is pending.`);if(this.logDebug(`Received response for load request #${i}`),null===this.parent&&null!==s)return void this.logWarn("Lazy parent node was removed while loading: discarding response.");this.setStatus(I.ok);const r=Date.now();this._loadSourceObject(t),l=Date.now()-r}else this._loadSourceObject(e),l=Date.now()-n}catch(t){throw this.logError("Error during load()",e,t),this._callEvent("error",{error:t}),this.setStatus(I.error,{message:""+t}),t}finally{this._requestId=0,r=Date.now()-n,t.options.debugLevel>=3&&t.logInfo(`Load source took ${r/1e3} seconds (transfer: ${o/1e3}s, processing: ${l/1e3}s)`)}}async loadLazy(e=!1){const t=this.expanded;if(o(this.lazy,"load() requires a lazy node"),e||this.isUnloaded()){this.isLoaded()&&this.resetLazy(),this.setStatus(I.loading);try{const e=await this._callEvent("lazyLoad");if(!1===e)return void this.setStatus(I.ok);o(w(e)||e&&e.url,"The lazyLoad event must return a node list, `{url: ...}`, or false."),await this.load(e),t?(this.expanded=!0,this.tree.update(D.structure)):this.update()}catch(e){this.logError("Error during loadLazy()",e),this._callEvent("error",{error:e}),this.setStatus(I.error,{message:""+e})}}}log(...e){this.logDebug(...e)}logDebug(...e){this.tree.options.debugLevel>=4&&console.log(this.toString(),...e)}logError(...e){this.tree.options.debugLevel>=1&&console.error(this.toString(),...e)}logInfo(...e){this.tree.options.debugLevel>=3&&console.info(this.toString(),...e)}logWarn(...e){this.tree.options.debugLevel>=2&&console.warn(this.toString(),...e)}async makeVisible(e){let t;const i=new oe,s=[],n=this.getParentList(!1,!1),r=n.length,o=k(e,"noAnimation",!1),l=k(e,"scrollIntoView",!0);for(t=r-1;t>=0;t--){const e={noAnimation:o};s.push(n[t].setExpanded(!0,e))}return Promise.all(s).then((()=>{l&&this.tree?(this.tree.updatePendingModifications(),this.scrollIntoView().then((()=>{i.resolve()}))):i.resolve()})),i.promise()}moveTo(e,t="appendChild",i){let s;"over"===t&&(t="appendChild"),"prependChild"===t&&(e.children&&e.children.length?(t="before",e=e.children[0]):t="appendChild");const n=this.tree,r=this.parent,l="appendChild"===t?e:e.parent;if(this!==e){if(this.parent?l.isDescendantOf(this)&&a("Cannot move a node to its own descendant"):a("Cannot move system root"),l!==r&&r.triggerModifyChild("remove",this),1===this.parent.children.length){if(this.parent===l)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else s=this.parent.children.indexOf(this),o(s>=0,"invalid source parent"),this.parent.children.splice(s,1);if(this.parent=l,l.hasChildren())switch(t){case"appendChild":l.children.push(this);break;case"before":s=l.children.indexOf(e),o(s>=0,"invalid target parent"),l.children.splice(s,0,this);break;case"after":s=l.children.indexOf(e),o(s>=0,"invalid target parent"),l.children.splice(s+1,0,this);break;default:a(`Invalid mode '${t}'.`)}else l.children=[this];i&&e.visit(i,!0),l===r?l.triggerModifyChild("move",this):l.triggerModifyChild("add",this),n!==e.tree&&(this.logWarn("Cross-tree moveTo is experimental!"),this.visit((t=>{t.tree=e.tree}),!0)),setTimeout((()=>{n.update(D.any)}),0)}}async navigate(e,t){e=J[e]||e;const i=this.findRelatedNode(e);if(!i)return this.logWarn(`Could not find related node '${e}'.`),Promise.resolve(this);try{i.makeVisible({scrollIntoView:!1})}catch(e){}return i.setFocus(),!1===(null==t?void 0:t.activate)?Promise.resolve(this):i.setActive(!0,{event:null==t?void 0:t.event})}remove(){const e=this.tree,t=this.parent.children.indexOf(this);this.triggerModify("remove"),this.parent.children.splice(t,1),this.visit((t=>{t.removeMarkup(),e._unregisterNode(t)}),!0),e.update(D.structure)}removeChildren(){const e=this.tree;this.children&&(e.activeNode&&e.activeNode.isDescendantOf(this)&&e.activeNode.setActive(!1),e.focusNode&&e.focusNode.isDescendantOf(this)&&(e.focusNode=null),this.triggerModifyChild("remove",null),this.visit((t=>{e._unregisterNode(t)})),this.lazy?this.children=[]:this.children=null,this.isRootNode()||(this.expanded=!1),this.tree.update(D.structure))}removeMarkup(){this._rowElem&&(delete this._rowElem._wb_node,this._rowElem.remove(),this._rowElem=void 0)}_getRenderInfo(){const e={},t={},i=this.isColspan(),s=this._rowElem?this._rowElem.querySelectorAll("span.wb-col"):null;let n=0;for(const r of this.tree.columns)e[r.id]={id:r.id,idx:n,elem:s?s[n]:null,info:r},i||"*"===r.id||(t[r.id]=e[r.id]),n++;return{allColInfosById:e,renderColInfosById:t}}_createIcon(e,t,i,s){let n,r=this.getOption("icon");if(this._errorInfo?r=e.error:this._isLoading&&s&&(r=e.loading),!1===r)return null;"string"==typeof r||(r=this.statusNodeType?e[this.statusNodeType]:this.expanded?e.folderOpen:this.children?e.folder:this.lazy?e.folderLazy:e.doc),r?r.indexOf("<")>=0?n=f(r):Q.test(r)?n=f(`<i class="wb-icon" style="background-image: url('${r}');">`):(n=document.createElement("i"),n.className="wb-icon "+r):(n=document.createElement("i"),n.className="wb-icon"),i?t.replaceChild(n,i):t.appendChild(n);const o=this._callEvent("iconBadge",{iconSpan:n});let l=null;if(null!=o&&!1!==o){let e="",t="";x(o)?(l=""+o.badge,e=o.badgeClass?" "+o.badgeClass:"",t=o.badgeTooltip?` title="${o.badgeTooltip}"`:""):l="number"==typeof o?""+o:o,"string"==typeof l&&(l=f(`<span class="wb-badge${e}"${t}>${d(l)}</span>`)),l&&n.append(l)}return n}_render_markup(e){const t=this.tree,i=t.options,s=this.getOption("checkbox"),n=t.columns,r=this.getLevel(),l=t.isRowNav()?null:t.activeColIdx;let a,d=this._rowElem,c=null,h=null;const u=!d;o(u),o(!u||e&&e.after,"opts.after expected, unless updating"),o(!this.isRootNode()),d=document.createElement("div"),d.classList.add("wb-row"),d.style.top=this._rowIdx*G+"px",this._rowElem=d,d._wb_node=this;const p=document.createElement("span");p.classList.add("wb-node","wb-col"),d.appendChild(p);let f=0;s&&(c=document.createElement("i"),c.classList.add("wb-checkbox"),("radio"===s||this.parent.radiogroup)&&c.classList.add("wb-radio"),p.appendChild(c),f+=20);for(let e=r-1;e>0;e--)a=document.createElement("i"),a.classList.add("wb-indent"),p.appendChild(a),f+=20;(!i.minExpandLevel||r>i.minExpandLevel)&&(h=document.createElement("i"),h.classList.add("wb-expander"),p.appendChild(h),f+=20);this._createIcon(t.iconMap,p,null,!h)&&(f+=20);const g=document.createElement("span");g.classList.add("wb-title"),p.appendChild(g),p._ofsTitlePx=f,t.options.dnd.dragStart&&(p.draggable=!0);if(!this.isColspan()&&n.length>1){let e=0;for(const t of n){let i;e++,"*"===t.id?i=p:(i=document.createElement("span"),i.classList.add("wb-col"),d.appendChild(i)),e===l&&i.classList.add("wb-active"),t.classes&&i.classList.add(...t.classes.split(" ")),i.style.left=t._ofsPx+"px",i.style.width=t._widthPx+"px",u&&t.html&&"string"==typeof t.html&&(i.innerHTML=t.html)}}switch(e?e.after:"last"){case"first":t.nodeListElement.prepend(d);break;case"last":t.nodeListElement.appendChild(d);break;default:e.after.after(d)}e.isNew=!0,this._render_data(e)}_render_data(e){o(this._rowElem);const t=this.tree,i=t.options,s=this._rowElem,n=!!e.isNew,r=!!e.preventScroll,l=t.columns,a=this.isColspan(),d=s.querySelector("span.wb-node"),c=d.querySelector("span.wb-title"),h=t.element.scrollTop;if(this.titleWithHighlight?c.innerHTML=this.titleWithHighlight:c.textContent=this.title,r&&(t.element.scrollTop=h),!i.skeleton)if(a){const e=t.element.clientWidth;c.style.width=e-d._ofsTitlePx-7+"px"}else c.style.width=l[0]._widthPx-d._ofsTitlePx-7+"px";if(e.isDataChange=!0,this._render_status(e),this.statusNodeType)this._callEvent("renderStatusNode",{isNew:n,nodeElem:d,isColspan:a});else if(this.parent){const e=this._getRenderInfo();this._callEvent("render",{isNew:n,nodeElem:d,isColspan:a,allColInfosById:e.allColInfosById,renderColInfosById:e.renderColInfosById})}}_render_status(e){const t=this.tree,i=t.iconMap,s=t.options,n=this.type?t.types[this.type]:null,r=this._rowElem,o=r.querySelector("span.wb-node"),l=o.querySelector("i.wb-expander"),a=o.querySelector("i.wb-checkbox"),d=["wb-row"];if(this.expanded&&d.push("wb-expanded"),this.lazy&&d.push("wb-lazy"),this.selected&&d.push("wb-selected"),this._partsel&&d.push("wb-partsel"),this===t.activeNode&&d.push("wb-active"),this===t.focusNode&&d.push("wb-focus"),this._errorInfo&&d.push("wb-error"),this._isLoading&&d.push("wb-loading"),this.isColspan()&&d.push("wb-colspan"),this.statusNodeType&&d.push("wb-status-"+this.statusNodeType),this.match&&d.push("wb-match"),this.subMatchCount&&d.push("wb-submatch"),s.skeleton&&d.push("wb-skeleton"),r.className=d.join(" "),this.classes&&r.classList.add(...this.classes),n&&n.classes&&r.classList.add(...n.classes),l){let e=null;this._isLoading?e=i.loading:this.isExpandable(!1)?e=this.expanded?i.expanderExpanded:i.expanderCollapsed:this.lazy&&null==this.children&&(e=i.expanderLazy),null==e?l.classList.add("wb-indent"):Q.test(e)?l.style.backgroundImage=`url('${e}')`:l.className="wb-expander "+e}if(a){let e="wb-checkbox ";this.isRadio()?(e+="wb-radio ",this.selected?e+=i.radioChecked:e+=i.radioUnchecked):this.selected?e+=i.checkChecked:this._partsel?e+=i.checkUnknown:e+=i.checkUnchecked,a.className=e}if(!e.isNew){let e=0;for(const i of r.children)i.classList.toggle("wb-active",e++===t.activeColIdx);const i=o.querySelector("i.wb-icon");i&&this._createIcon(t.iconMap,o,i,!l)}if(!1!==e.resizeCols&&!this.isColspan()){const e=r.querySelectorAll("span.wb-col");let t=0,i=0;for(const s of this.tree.columns){const n=e[t];n.style.left=`${i}px`,n.style.width=`${s._widthPx}px`,t++,i+=s._widthPx}}}_render(e){const t=Object.assign({change:D.data},e);switch(this._rowElem||(t.change=D.row),t.change){case"status":this._render_status(t);break;case"data":this._render_data(t);break;case"row":this._render_markup(t);break;default:a(`Invalid change type '${t.change}'.`)}}resetLazy(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=null,this.tree.update(D.structure)}toDict(e=!1,t){const i={};if(ae.forEach((e=>{const t=this[e];t instanceof Set?t.size&&(i[e]=Array.prototype.join.call(t.keys()," ")):(t||!1===t||0===t)&&(i[e]=t)})),E(this.data)||(i.data=y({},this.data),E(i.data)&&delete i.data),t){const s=t(i,this);if(!1===s)return!1;"skip"===s&&(e=!1)}if(e&&w(this.children)){i.children=[];for(let e=0,s=this.children.length;e<s;e++){const s=this.children[e];if(!s.isStatusNode()){const e=s.toDict(!0,t);!1!==e&&i.children.push(e)}}}return i}getOption(e,t){const i=this.tree;let s=i.options;e.indexOf(".")>=0&&([s,e]=e.split("."));const n=s[e];if("function"==typeof n){const e=n.call(i,{type:"resolve",tree:i,node:this});if(void 0!==e)return e}if(void 0!==this[e])return this[e];const r=this.type?i.types[this.type]:void 0,o=r?r[e]:void 0;return void 0!==o?o:null!=n?n:t}async scrollIntoView(e){const t=Object.assign({node:this},e);return this.tree.scrollTo(t)}async setActive(e=!0,t){const i=this.tree,s=i.activeNode,n=null==t?void 0:t.retrigger,r=null==t?void 0:t.focusTree,o=!1!==(null==t?void 0:t.focusNode),l=null==t?void 0:t.noEvents,a=null==t?void 0:t.event;if(!l)if(e){if(s!==this||n){if(!1===(null==s?void 0:s._callEvent("deactivate",{nextNode:this,event:a}))||!1===this._callEvent("beforeActivate",{prevNode:s,event:a}))return;i.activeNode=null,null==s||s.update(D.status)}}else(s===this||n)&&this._callEvent("deactivate",{nextNode:null,event:a});return s!==this&&(e&&(i.activeNode=this,(o||r)&&(i.focusNode=this),r&&i.setFocus()),null==s||s.update(D.status),this.update(D.status)),t&&null!=t.colIdx&&t.colIdx!==i.activeColIdx&&i.isCellNav()&&i.setColumn(t.colIdx),e&&!l&&this._callEvent("activate",{prevNode:s,event:a}),this.makeVisible()}async setExpanded(e=!0,t){const{force:i,scrollIntoView:s,immediate:n}=null!=t?t:{};if(!e&&this.isExpanded()&&this.getLevel()<=this.tree.getOption("minExpandLevel")&&!i)return void this.logDebug("Ignored collapse request below expandLevel.");if(!e==!this.expanded)return;e&&this.getOption("autoCollapse")&&this.collapseSiblings(t),e&&this.lazy&&null==this.children&&await this.loadLazy(),this.expanded=e;const r={immediate:n};if(this.tree.update(D.structure,r),e&&s){const e=this.getLastChild();e&&(this.tree.updatePendingModifications(),e.scrollIntoView({topNode:this}))}}setFocus(e=!0){o(!!e,"blur is not yet implemented");const t=this.tree.focusNode;this.tree.focusNode=this,null==t||t.update(),this.update()}setIcon(e){this.icon=e,this.update()}setKey(e,t){throw new Error("Not yet implemented")}update(e=D.data){o(e===D.status||e===D.data),this.tree.update(e,this)}getSelectedNodes(e=!1){const t=[];return this.visit((i=>{if(i.selected&&(t.push(i),!0===e))return"skip"})),t}toggleSelected(e){let t=this.isSelected();return t=void 0!==t||this.isRadio()?!t:this._anySelectable(),this.setSelected(t,e)}_anySelectable(){let e=!1;return this.visit((t=>{if(!1===t.selected&&!t.unselectable&&!t.hasChildren()&&!t.parent.radiogroup)return e=!0,!1})),e}_changeSelectStatusProps(e){let t=!1;switch(e){case!1:t=this.selected||this._partsel,this.selected=!1,this._partsel=!1;break;case!0:t=!this.selected||!this._partsel,this.selected=!0,this._partsel=!0;break;case void 0:t=this.selected||!this._partsel,this.selected=!1,this._partsel=!0;break;default:a(`Invalid state: ${e}`)}return t&&this.update(),t}fixSelection3AfterClick(e){const t=!!(null==e?void 0:e.force),i=this.isSelected();this.visit((e=>{if(e.radiogroup)return"skip";!t&&e.getOption("unselectable")||e._changeSelectStatusProps(i)})),this.fixSelection3FromEndNodes()}fixSelection3FromEndNodes(e){const t=!!(null==e?void 0:e.force);o("hier"===this.tree.options.selectMode,"expected selectMode 'hier'");const i=e=>{let s;const n=e.children;if(n&&n.length){let e=!0,t=!1;for(let s=0,r=n.length;s<r;s++){const r=n[s],o=i(r);!1!==o&&(t=!0),!0!==o&&(e=!1)}s=!!e||!!t&&void 0}else s=!!e.selected;return e._partsel&&!e.selected&&e.lazy&&null==e.children&&(s=void 0),!t&&e.getOption("unselectable")||e._changeSelectStatusProps(s),s};i(this),this.visitParents((e=>{let t;const i=e.children;let s=!0,n=!1;for(let e=0,r=i.length;e<r;e++){const r=i[e];t=!!r.selected,(t||r._partsel)&&(n=!0),t||(s=!1)}t=!!s||!!n&&void 0,e._changeSelectStatusProps(t)}))}setSelected(e=!0,t){const i=this.tree,s=!(null==t?void 0:t.noEvents),n=this.isSelected(),r=this.parent&&this.parent.radiogroup,o=i.options.selectMode,l=(null==t?void 0:t.force)||!this.getOption("unselectable");return e=!!e,l?(null==t?void 0:t.propagateDown)&&"multi"===o?(i.runWithDeferredUpdate((()=>{this.visit((t=>{t.setSelected(e)}))})),n):(e===n||s&&!1===this._callEvent("beforeSelect",{flag:e})||(i.runWithDeferredUpdate((()=>{if(r){if(!e&&!(null==t?void 0:t.force))return n;for(const e of this.parent.children)e.selected=e===this}else this.selected=e,"hier"===o?this.fixSelection3AfterClick():"single"===o&&i.visit((e=>{e.selected=!1}))})),s&&this._callEvent("select",{flag:e})),n):n}setStatus(e,t){const i=this.tree,s=null==t?void 0:t.message,n=null==t?void 0:t.details;let r=null;const l=e=>{const t=this.children,s=t?t[0]:null;return o(e.statusNodeType),o(!s||!s.isStatusNode()),r=this.addNode(e,"prependChild"),r.match=!0,i.update(D.structure),r};switch((()=>{const e=this.children;e&&e.length&&e[0].isStatusNode()&&e[0].remove()})(),e){case"ok":this._isLoading=!1,this._errorInfo=null;break;case"loading":this._isLoading=!0,this._errorInfo=null,this.parent?this.update(D.status):l({statusNodeType:e,title:i.options.strings.loading+(s?" ("+s+")":""),checkbox:!1,colspan:!0,tooltip:n});break;case"error":l({statusNodeType:e,title:i.options.strings.loadError+(s?" ("+s+")":""),checkbox:!1,colspan:!0,tooltip:n}),this._isLoading=!1,this._errorInfo={message:s,details:n};break;case"noData":l({statusNodeType:e,title:s||i.options.strings.noData,checkbox:!1,colspan:!0,tooltip:n}),this._isLoading=!1,this._errorInfo=null;break;default:a("invalid node status "+e)}return i.update(D.structure),r}setTitle(e){this.title=e,this.update()}_sortChildren(e,t){const i=this.children;if(i&&(i.sort(e),t))for(let s=0,n=i.length;s<n;s++)i[s].children&&i[s]._sortChildren(e,t)}sortChildren(e=ee,t=!1){this._sortChildren(e||ee,t),this.tree.update(D.structure)}triggerModifyChild(e,t,i){this.logDebug(`modifyChild(${e})`,i,t),this.tree.options.modifyChild&&(t&&t.parent!==this&&a("child "+t+" is not a child of "+this),this._callEvent("modifyChild",y({operation:e,child:t},i)))}triggerModify(e,t){this.parent.triggerModifyChild(e,this,t)}visit(e,t=!1){let i=!0;const s=this.children;if(!0===t&&(i=e(this),!1===i||"skip"===i))return i;if(s)for(let t=0,n=s.length;t<n&&(i=s[t].visit(e,!0),!1!==i);t++);return i}visitParents(e,t=!1){if(t&&!1===e(this))return!1;let i=this.parent;for(;i;){if(!1===e(i))return!1;i=i.parent}return!0}visitSiblings(e,t=!1){const i=this.parent.children;for(let s=0,n=i.length;s<n;s++){const n=i[s];if((t||n!==this)&&!1===e(n))return!1}return!0}isMatched(){return!(this.tree.filterMode&&!this.match)}}de.sequence=0;
69
69
  /*!
70
70
  * Wunderbaum - ext-edit
71
71
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
72
- * v0.5.3, Sun, 15 Oct 2023 16:42:56 GMT (https://github.com/mar10/wunderbaum)
72
+ * v0.5.4, Sun, 15 Oct 2023 16:43:28 GMT (https://github.com/mar10/wunderbaum)
73
73
  */
74
74
  class ce extends A{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxlength:null,trigger:[],trim:!0,select:!0,slowClickDelay:1e3,validity:!0,beforeEdit:null,edit:null,apply:null}),this.curEditNode=null,this.relatedNode=null,this.debouncedOnChange=U(this._onChange.bind(this),this.getPluginOption("debounce"))}_applyChange(e,t,i,s){let n;t.log(`_applyChange(${e})`,s),i.classList.add("wb-busy"),i.classList.remove("wb-error");try{n=t._callEvent(e,s)}catch(s){t.logError(`Error in ${e} event handler`,s),i.classList.add("wb-error"),i.classList.remove("wb-busy")}return n instanceof Promise||(n=Promise.resolve(n)),n.catch((s=>{t.logError(`Error in ${e} event promise`,s),i.classList.add("wb-error")})).finally((()=>{i.classList.remove("wb-busy")})),n}_onChange(e){const t=ue.getEventInfo(e),i=t.node,s=t.colElem;i&&0!==t.colIdx?this._applyChange("change",i,s,{info:t,event:e,inputElem:e.target,inputValue:ue.util.getValueFromElem(e.target)}):this.tree.log("Ignored change event for removed element or node title")}init(){super.init(),_(this.tree.element,"change",".contenteditable,input,textarea,select",(e=>{this.debouncedOnChange(e)}))}_preprocessKeyEvent(e){const t=e.event,s=b(t),n=this.tree,r=this.getPluginOption("trigger");if(this.isEditingTitle()){switch(s){case"Enter":return this._stopEditTitle(!0,{event:t}),!1;case"Escape":return this._stopEditTitle(!1,{event:t}),!1}return!1}if(n.isRowNav()||0===n.activeColIdx){switch(s){case"Enter":if(r.indexOf("macEnter")>=0&&i)return this.startEditTitle(),!1;break;case"F2":if(r.indexOf("F2")>=0)return this.startEditTitle(),!1}return!0}return!0}isEditingTitle(e){return e?this.curEditNode===e:!!this.curEditNode}startEditTitle(e){e=null!=e?e:this.tree.getActiveNode();const t=this.getPluginOption("validity"),i=this.getPluginOption("select");if(!e)return;this.tree.logDebug(`startEditTitle(node=${e})`);let s=e._callEvent("edit.beforeEdit");if(!1===s)return void e.logInfo("beforeEdit canceled operation.");if(!0===s||!s){s=`<input type=text class="wb-input-edit" tabindex=-1 value="${d(e.title)}" required autocorrect=off>`}const n=e.getColElem(0).querySelector(".wb-title");n.innerHTML=s;const r=n.firstElementChild;t&&r.addEventListener("keydown",(e=>{r.setCustomValidity(""),r.reportValidity()})),r.focus(),i&&r.select(),this.curEditNode=e,e._callEvent("edit.edit",{inputElem:r})}stopEditTitle(e){return this._stopEditTitle(e,{})}_stopEditTitle(e,t){null!=t||(t={});const i=document.activeElement;let s=i?u(i):null;const n=this.curEditNode,r=!!t.forceClose,o=this.getPluginOption("validity");if(s&&this.getPluginOption("trim")&&(s=s.trim()),n)if(n.logDebug(`stopEditTitle(${e})`,t,i,s),e&&null!==s&&s!==n.title){const e=i.validationMessage;if(e)throw new Error(`Input validation failed for "${s}": ${e}.`);const t=n.getColElem(0);this._applyChange("edit.apply",n,t,{oldValue:n.title,newValue:s,inputElem:i}).then((e=>{const t=i.validationMessage;if(o&&t&&!1!==e)throw new Error(`Edit apply validation failed for "${s}": ${t}.`);(r||!1!==e)&&(null==n||n.setTitle(s),this.curEditNode._render({preventScroll:!0}),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus())})).catch((e=>{n.logError(e)}))}else this.curEditNode._render({preventScroll:!0}),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus();else this.tree.logDebug("stopEditTitle: not in edit mode.")}createNode(e="after",t,i){const s=this.tree;if(o(t=null!=t?t:s.getActiveNode(),"No node was passed, or no node is currently active."),e=e||"prependChild",null==i?i={title:""}:"string"==typeof i?i={title:i}:o(x(i)),("prependChild"===e||"appendChild"===e)&&(null==t?void 0:t.isExpandable(!0)))return void t.setExpanded().then((()=>{this.createNode(e,t,i)}));const n=t.addNode(i,e);n.setClass("wb-edit-new"),this.relatedNode=t,n.match=!0,n.makeVisible({noAnimation:!0}).then((()=>{this.startEditTitle(n)}))}}
75
75
  /*!
@@ -81,7 +81,7 @@ class ce extends A{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxle
81
81
  * https://github.com/mar10/wunderbaum
82
82
  *
83
83
  * Released under the MIT license.
84
- * @version v0.5.3
85
- * @date Sun, 15 Oct 2023 16:42:56 GMT
86
- */class he extends de{constructor(e){super(e,null,{key:"__root__",title:e.id})}toString(){return`WbSystemRoot@${this.key}<'${this.tree.id}'>`}}class ue{constructor(e){this.enabled=!0,this.data={},this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.treeRowCount=0,this._disableUpdateCount=0,this._disableUpdateIgnoreCount=0,this.activeNode=null,this.focusNode=null,this.types={},this.columns=[],this._columnsById={},this.pendingChangeTypes=new Set,this._util=O,this.filterMode=null,this.activeColIdx=0,this._cellNavMode=!1,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this.log=this.logDebug;const t=this.options=y({id:null,source:null,element:null,debugLevel:3,header:null,rowHeightPx:G,iconMap:"bootstrap",columns:null,types:null,enabled:!0,fixedCol:!1,showSpinner:!1,checkbox:!1,minExpandLevel:0,emptyChildListExpandable:!1,skeleton:!1,connectTopBreadcrumb:null,selectMode:"multi",navigationModeOption:null,quicksearch:!0,iconBadge:null,change:null,error:null,receive:null,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e),i=new oe;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){this.logError("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++ue.sequence,this.root=new he(this),this._registerExtension(new W(this)),this._registerExtension(new ce(this)),this._registerExtension(new K(this)),this._registerExtension(new se(this)),this._registerExtension(new re(this)),this._registerExtension(new B(this)),this._updateViewportThrottled=S(this._updateViewportImmediately.bind(this),{}),this.columns=t.columns,delete t.columns,!this.columns||!this.columns.length){const e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}t.types&&this.setTypes(t.types,!0),delete t.types,this.element=v(t.element),o(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){o(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||`col_${this.columns.length}`,title:""+t.textContent,width:"*"})}else{const e="<span class='wb-col'></span>".repeat(this.columns.length);if(this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`,!n){this.element.querySelector("div.wb-header").style.display="none"}}this.element.innerHTML+='\n <div class="wb-list-container">\n <div class="wb-node-list"></div>\n </div>',this.listContainerElement=this.element.querySelector("div.wb-list-container"),this.nodeListElement=this.listContainerElement.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.element.classList.toggle("wb-grid",this.columns.length>1),this._initExtensions(),["enabled","fixedCol"].forEach((e=>{null!=t[e]&&this.setOption(e,t[e])})),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{null==t.navigationModeOption?this.isGrid()?this.setNavigationOption(M.cell):this.setNavigationOption(M.row):this.setNavigationOption(t.navigationModeOption),i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),this.update(D.any),this.element.addEventListener("scroll",(e=>{this.update(D.scroll)})),this.resizeObserver=new ResizeObserver((e=>{this.update(D.resize)})),this.resizeObserver.observe(this.element),_(this.nodeListElement,"click","div.wb-row",(t=>{const i=ue.getEventInfo(t),s=i.node,n=t;if(!1===this._callEvent("click",{event:t,node:s,info:i}))return this.lastClickTime=Date.now(),!1;if(s){if(n.ctrlKey)return void s.toggleSelected();const r=this.getOption("edit.trigger"),o=this.getOption("edit.slowClickDelay");r.indexOf("clickActive")>=0&&"title"===i.region&&s.isActive()&&(!o||Date.now()-this.lastClickTime<o)&&this._callMethod("edit.startEditTitle",s),i.colIdx>=0?s.setActive(!0,{colIdx:i.colIdx,event:t}):s.setActive(!0,{event:t}),i.region===T.expander?s.setExpanded(!s.isExpanded(),{scrollIntoView:!1!==e.scrollIntoViewOnExpandClick}):i.region===T.checkbox&&s.toggleSelected()}this.lastClickTime=Date.now()})),_(this.nodeListElement,"dblclick","div.wb-row",(e=>{const t=ue.getEventInfo(e),i=t.node;if(!1===this._callEvent("dblclick",{event:e,node:i,info:t}))return!1;i&&0===t.colIdx&&i.isExpandable()&&(this._callMethod("edit._stopEditTitle"),i.setExpanded(!i.isExpanded()))})),_(this.element,"keydown",(e=>{const t=ue.getEventInfo(e),i=b(e),s=t.node||this.getFocusNode();this._callHook("onKeyEvent",{event:e,node:s,info:t,eventName:i})})),_(this.element,"focusin focusout",(e=>{const i="focusin"===e.type,s=ue.getNode(e);this._callEvent("focus",{flag:i,event:e}),i&&this.isRowNav()&&!this.isEditing()&&(t.navigationModeOption===M.row?null==s||s.setActive():this.setCellNav()),i||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof ue)return e;if(e instanceof de)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(const t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return o(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}get iconMap(){const e=this.options.iconMap;return"string"==typeof e?Y[e]:e}static getNode(e){if(!e)return null;if(e instanceof de)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}*[Symbol.iterator](){yield*this.root}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(const e of this.extensionList)e.init()}_registerNode(e){const t=e.key;o(null!=t&&!this.keyMap.has(t),`Missing or duplicate key: '${t}'.`),this.keyMap.set(t,e);const i=e.refKey;if(i){const t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,e.removeMarkup()}_callHook(e,t={}){let i;const s=y({},{tree:this,options:this.options,result:void 0},t);for(const t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,y({type:e,tree:this,util:this._util},t))}_getNodeByRowIdx(e){let t=null;return this.visitRows((i=>{if(i._rowIdx===e)return t=i,!1})),t}getTopmostVpNode(e=!0){const t=this.element.scrollTop;let i;return i=e?Math.ceil((t-1)/G):Math.floor(t/G),this._getNodeByRowIdx(i)}getLowestVpNode(e=!0){const t=this.element,i=this.headerElement.clientHeight,s=t.scrollTop,n=t.clientHeight-i;let r;return r=e?Math.floor((s+n)/G)-1:Math.ceil((s+n)/G)-1,r=Math.min(r,this.count(!0)-1),this._getNodeByRowIdx(r)}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof de?s=t:(s=this.getActiveNode(),o(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:a(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.treeRowCount=0,this.activeNode=null,this.focusNode=null,this.update(D.structure)}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(e.indexOf(".")>=0){const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}else switch(this.options[e]=t,e){case"checkbox":this.update(D.any);break;case"enabled":this.setEnabled(!!t);break;case"fixedCol":this.element.classList.toggle("wb-fixed-col",!!t)}}hasFocus(){return this.element.contains(document.activeElement)}hasHeader(){const e=this.options.header;return this.isGrid()?!1!==e:!!e}runWithDeferredUpdate(e,t=null){try{this.enableUpdate(!1);const t=e();return o(!(t instanceof Promise)),t}finally{this.enableUpdate(!0)}}async expandAll(e=!0,t){await this.root.expandAll(e,t)}selectAll(e=!0){return this.root.setSelected(e,{propagateDown:!0})}toggleSelect(){this.selectAll(this.root._anySelectable())}getSelectedNodes(e=!1){return this.root.getSelectedNodes(e)}_selectRange(e){this.logDebug("_selectRange",e),a("Not yet implemented.")}count(e=!1){return e?this.treeRowCount:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findKey(e){return this.keyMap.get(e)||null}findNextNode(e,t){let i=null;const s=this.getFirstChild(),n="string"==typeof e?function(e){e=c(e);const t=new RegExp("^"+e,"i");return function(e){return t.test(e.title)}}(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null;const n=Math.floor(this.listContainerElement.clientHeight/G);switch(t){case"parent":case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((e=>{if(e.isVisible())return s=e,!1}));break;case"last":this.visit((e=>{e.isVisible()&&(s=e)}));break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":{const t=this.getLowestVpNode();s=e._rowIdx<t._rowIdx?t:this._getNextNodeInView(e,n)}break;case"pageUp":if(0===e._rowIdx)s=e;else{const t=this.getTopmostVpNode();s=e._rowIdx>t._rowIdx?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}*format_iter(e,t){yield*this.root.format_iter(e,t)}format(e,t){return this.root.format(e,t)}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){const t=e.target,i=t.classList,s=t.closest("span.wb-col"),n=ue.getNode(t),r=n?n.tree:ue.getTree(e),o={event:e,canonicalName:b(e),tree:r,node:n,region:T.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))o.region=T.title;else if(i.contains("wb-expander"))o.region=n.isExpandable()?T.expander:T.prefix;else if(i.contains("wb-checkbox"))o.region=T.checkbox;else if(i.contains("wb-icon"))o.region=T.icon;else if(i.contains("wb-node"))o.region=T.title;else if(s){o.region=T.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);o.colIdx=e}else{if(!i.contains("wb-row"))return"mousemove"===e.type||e instanceof KeyboardEvent||null==r||r.logWarn("getEventInfo(): not found",e,o),o;o.region=T.title}return-1===o.colIdx&&(o.colIdx=0),o.colDef=null==r?void 0:r.columns[o.colIdx],null!=o.colDef&&(o.colId=o.colDef.id),o}toString(){return`Wunderbaum<'${this.id}'>`}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){let e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&console.log(this.toString(),...e)}logError(...e){this.options.debugLevel>=1&&console.error(this.toString(),...e)}logInfo(...e){this.options.debugLevel>=3&&console.info(this.toString(),...e)}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&console.warn(this.toString(),...e)}scrollTo(e){let t,i;e instanceof de?t=e:(i=e,t=i.node),o(t&&null!=t._rowIdx);const s=this.element,n=this.headerElement.clientHeight,r=s.scrollTop,l=s.clientHeight,a=t._rowIdx*G+n,d=n,c=a-r,h=c+G,u=null==i?void 0:i.topNode;let p=null;c>=d?h<=l||(p=a+G-l+2):p=a-d-2,null!=p&&(this.log(`scrollTo(${a}): ${r} => ${p}`),s.scrollTop=p,u&&this.scrollTo(u))}scrollToHorz(){const e=this.columns[0]._widthPx,t=this.element.clientWidth,i=this.element.scrollLeft,s=this.getActiveColElem(),n=Number.parseInt(null==s?void 0:s.style.left,10),r=n+Number.parseInt(null==s?void 0:s.style.width,10);let o=i;n-i<e?o=n-e:r-i>t&&(o=r-t),o=Math.max(0,o),this.log(`scrollToHorz(${this.activeColIdx}): ${n}..${r}, fixedOfs=${e}, vpWidth=${t}, curLeft=${i} -> ${o}`),this.element.scrollLeft=o}setColumn(e){var t;if(o(this.isCellNav()),o(0<=e&&e<this.columns.length),this.activeColIdx=e,this.hasHeader())for(const t of this.headerElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}null===(t=this.activeNode)||void 0===t||t.update(D.status);for(const t of this.nodeListElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}this.scrollToHorz()}setActiveNode(e,t=!0,i){var s;null===(s=this.findKey(e))||void 0===s||s.setActive(t,i)}setFocus(e=!0){e?this.element.focus():this.element.blur()}update(e,t,i){if(this._disableUpdateCount)return void this._disableUpdateIgnoreCount++;t instanceof de||(i=t,t=null);const s=!!k(i,"immediate"),n=L,r=this.pendingChangeTypes;switch(e){case D.any:case D.colStructure:r.add(n.header),r.add(n.clearMarkup),r.add(n.redraw),r.add(n.scroll);break;case D.resize:r.add(n.header),r.add(n.redraw);break;case D.structure:r.add(n.redraw);break;case D.scroll:r.add(n.scroll);break;case D.row:case D.data:case D.status:o(t,`Option '${e}' requires a node.`),t._rowElem&&t._render({change:e});break;default:a(`Invalid change type '${e}'.`)}if(e===D.colStructure){const e=this.isGrid();this.element.classList.toggle("wb-grid",e),!e&&this.isCellNav()&&this.setCellNav(!1)}r.size>0&&(s?this._updateViewportImmediately():this._updateViewportThrottled())}setEnabled(e=!0){const t=this.enabled;return this.enabled=!!e,this.element.classList.toggle("wb-disabled",!e),t}isEnabled(){return this.enabled}isGrid(){return this.columns&&this.columns.length>1}isCellNav(){return!!this._cellNavMode}isRowNav(){return!this._cellNavMode}setCellNav(e=!0){var t;const i=this._cellNavMode;this._cellNavMode=!!e,e&&!i&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",e),null===(t=this.activeNode)||void 0===t||t.update(D.status)}setNavigationOption(e,t=!1){if(this.isGrid()||e===M.row)switch(this.options.navigationModeOption=e,e){case M.cell:this.setCellNav(!0);break;case M.row:this.setCellNav(!1);break;case M.startCell:t&&this.setCellNav(!0);break;case M.startRow:t&&this.setCellNav(!1);break;default:a(`Invalid mode '${e}'.`)}else this.logWarn("Plain trees only support row navigation mode.")}setStatus(e,t){return this.root.setStatus(e,t)}setTypes(e,t=!0){o(x(e)),t?this.types=e:y(this.types,e);for(const e of Object.values(this.types))e.classes&&(e.classes=N(e.classes))}sortChildren(e=ee,t=!1){this.root.sortChildren(e,t)}toDictArray(e){var t;return null!==(t=this.root.toDict(!0,e).children)&&void 0!==t?t:[]}_updateColumnWidths(){const e=this.element.clientWidth,t=this.columns,i=t[0];let s=0,n=0,r=0,o=!1;if("*"!==i.id)throw new Error(`First column must have id '*': got '${i.id}'.`);this._columnsById={};for(const e of t){this._columnsById[e.id]=e;const t=e.width;if("*"===e.id&&e!==i)throw new Error(`Column id '*' must be defined only once: '${e.title}'.`);if(t&&"*"!==t)if("number"==typeof t)e._weight=t,n+=t;else if("string"==typeof t&&t.endsWith("px")){e._weight=0;const i=parseFloat(t.slice(0,-2));e._widthPx!=i&&(o=!0,e._widthPx=i),r+=i}else a(`Invalid column width: ${t} (expected string ending with 'px' or number, e.g. "<num>px" or <int>).`);else e._weight=1,n+=1}const l=Math.max(0,e-r);let d=0;for(const e of t){let t;if(e._weight){const i=e.minWidth;t="number"==typeof i?i:"string"==typeof i&&i.endsWith("px")?parseFloat(i.slice(0,-2)):4;const s=Math.max(t,l*e._weight/n);e._widthPx!=s&&(o=!0,e._widthPx=s)}e._ofsPx=d,d+=e._widthPx}t[t.length-1]._widthPx-=0,s=d-0;const c=`${s}px`;return this.headerElement.style.width=c,this.listContainerElement.style.width=c,o}_renderHeaderMarkup(){o(this.headerElement);const e=this.hasHeader();if(p(this.headerElement,e),!e)return;const t=this.columns.length,i=this.headerElement.querySelector(".wb-row");o(i),i.innerHTML="<span class='wb-col'></span>".repeat(t);for(let e=0;e<t;e++){const s=this.columns[e],n=i.children[e];n.style.left=s._ofsPx+"px",n.style.width=s._widthPx+"px","string"==typeof s.headerClasses?s.headerClasses&&n.classList.add(...s.headerClasses.split(" ")):s.classes&&n.classList.add(...s.classes.split(" "));const r=d(s.title||s.id);let o="";s.tooltip&&(o=h(s.tooltip),o=` title="${o}"`);let l="";e<t-1&&(l='<span class="wb-col-resizer"></span>'),n.innerHTML=`<span class="wb-col-title"${o}>${r}</span>${l}`,this.isCellNav()&&n.classList.toggle("wb-active",e===this.activeColIdx)}}updatePendingModifications(){this.pendingChangeTypes.size>0&&this._updateViewportImmediately()}_updateViewportImmediately(){var e;if(this._disableUpdateCount)return this.log(`_updateViewportImmediately() IGNORED (disable level: ${this._disableUpdateCount})`),void this._disableUpdateIgnoreCount++;const t=L,i=new Set(this.pendingChangeTypes);this.pendingChangeTypes.clear();if(i.has(t.scroll)&&1===i.size)this._updateRows({newNodesOnly:!0});else{if(this.log("_updateViewportImmediately():",i),!1!==this.options.adjustHeight){let e=this.listContainerElement.clientHeight;const t=this.headerElement.clientHeight,i=this.element.clientHeight-t-1;Math.abs(e-i)>1&&(this.listContainerElement.style.height=i+"px",e=i)}i.has(t.clearMarkup)&&this.visit((e=>{e.removeMarkup()})),i.has(t.header)&&(this._updateColumnWidths(),this._renderHeaderMarkup()),this._updateRows()}if(this.options.connectTopBreadcrumb){let t=null===(e=this.getTopmostVpNode(!0))||void 0===e?void 0:e.getPath(!1,"title"," > ");t=t?t+" >":"",this.options.connectTopBreadcrumb.textContent=t}this._callEvent("update")}_updateRows(e){const t=!!(e=Object.assign({newNodesOnly:!1},e)).newNodesOnly,i=this.element.clientHeight,s=this.element.scrollTop;let n=Math.max(0,s/22-5);n=Math.floor(n),n%2&&n--;let r=Math.max(0,(s+i)/22+5);r=Math.ceil(r);const o=new Set;this.nodeListElement.childNodes.forEach((e=>{const t=e;o.add(t._wb_node)}));let l=0,a=0,d=!1,c="first";this.visitRows((function(e){const i=e._rowElem;e._rowIdx!==l&&(e._rowIdx=l,d=!0),l<n||l>r?i&&(c=i):i&&t?(o.delete(e),i.style.top=l*G+"px",c=i):(o.delete(e),i&&(i.style.top=l*G+"px"),e._render({top:a,after:c}),c=e._rowElem),l++,a+=22})),this.treeRowCount=l;for(const e of o)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=`${a}px`,d}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,l,a,d=0,c=!1===(t=t||{}).includeSelf,h=t.start||this.root.children[0];const u=!!t.includeHidden,p=!u&&"hide"===this.filterMode;for(n=h.parent;n;){for(l=n.children,s=l.indexOf(h)+d,o(s>=0,`Could not find ${h} in parent's children: ${n}`),i=s;i<l.length;i++){if(h=l[i],h===a)return!1;if(!p||h.statusNodeType||h.match||h.subMatchCount){if(!c&&!1===e(h))return!1;if(c=!1,h.children&&h.children.length&&(u||h.expanded)&&(r=h.visit((t=>t!==a&&(!p||t.match||t.subMatchCount?!1!==e(t)&&(u||!t.children||t.expanded?void 0:"skip"):"skip")),!1),!1===r))return!1}}h=n,n=n.parent,d=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),o(t.start,"`wrap` option requires `start`"),a=t.start,t.wrap=!1,n=this.root,d=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=t.start||this.root.children[0];const o=!!t.includeHidden;if(!1!==t.includeSelf&&!1===e(r))return!1;for(;;){if(n=r.parent,i=n.children,i[0]===r){if(r=n,!r.parent)break;i=n.children}else for(s=i.indexOf(r),r=i[s-1];(o||r.expanded)&&r.children&&r.children.length;)i=r.children,n=r,r=i[i.length-1];if((o||r.isVisible())&&!1===e(r))return!1}return!0}load(e){return this.clear(),this.root.load(e)}enableUpdate(e){e?(o(this._disableUpdateCount>0,"enableUpdate(true) was called too often"),this._disableUpdateCount--,0===this._disableUpdateCount&&(this.logDebug(`enableUpdate(): active again. Re-painting to catch up with ${this._disableUpdateIgnoreCount} ignored update requests...`),this._disableUpdateIgnoreCount=0,this.update(D.any,{immediate:!0}))):this._disableUpdateCount++}filterNodes(e,t){return this.extensions.filter.filterNodes(e,t)}filterBranches(e,t){return this.extensions.filter.filterBranches(e,t)}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}ue.sequence=0,ue.version="v0.5.3",ue.util=O,e.Wunderbaum=ue}));
84
+ * @version v0.5.4
85
+ * @date Sun, 15 Oct 2023 16:43:28 GMT
86
+ */class he extends de{constructor(e){super(e,null,{key:"__root__",title:e.id})}toString(){return`WbSystemRoot@${this.key}<'${this.tree.id}'>`}}class ue{constructor(e){this.enabled=!0,this.data={},this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.treeRowCount=0,this._disableUpdateCount=0,this._disableUpdateIgnoreCount=0,this.activeNode=null,this.focusNode=null,this.types={},this.columns=[],this._columnsById={},this.pendingChangeTypes=new Set,this._util=O,this.filterMode=null,this.activeColIdx=0,this._cellNavMode=!1,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this.log=this.logDebug;const t=this.options=y({id:null,source:null,element:null,debugLevel:3,header:null,rowHeightPx:G,iconMap:"bootstrap",columns:null,types:null,enabled:!0,fixedCol:!1,showSpinner:!1,checkbox:!1,minExpandLevel:0,emptyChildListExpandable:!1,skeleton:!1,connectTopBreadcrumb:null,selectMode:"multi",navigationModeOption:null,quicksearch:!0,iconBadge:null,change:null,error:null,receive:null,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e),i=new oe;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){this.logError("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++ue.sequence,this.root=new he(this),this._registerExtension(new W(this)),this._registerExtension(new ce(this)),this._registerExtension(new K(this)),this._registerExtension(new se(this)),this._registerExtension(new re(this)),this._registerExtension(new B(this)),this._updateViewportThrottled=S(this._updateViewportImmediately.bind(this),{}),this.columns=t.columns,delete t.columns,!this.columns||!this.columns.length){const e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}t.types&&this.setTypes(t.types,!0),delete t.types,this.element=v(t.element),o(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){o(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||`col_${this.columns.length}`,title:""+t.textContent,width:"*"})}else{const e="<span class='wb-col'></span>".repeat(this.columns.length);if(this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`,!n){this.element.querySelector("div.wb-header").style.display="none"}}this.element.innerHTML+='\n <div class="wb-list-container">\n <div class="wb-node-list"></div>\n </div>',this.listContainerElement=this.element.querySelector("div.wb-list-container"),this.nodeListElement=this.listContainerElement.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.element.classList.toggle("wb-grid",this.columns.length>1),this._initExtensions(),["enabled","fixedCol"].forEach((e=>{null!=t[e]&&this.setOption(e,t[e])})),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{null==t.navigationModeOption?this.isGrid()?this.setNavigationOption(M.cell):this.setNavigationOption(M.row):this.setNavigationOption(t.navigationModeOption),i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),this.update(D.any),this.element.addEventListener("scroll",(e=>{this.update(D.scroll)})),this.resizeObserver=new ResizeObserver((e=>{this.update(D.resize)})),this.resizeObserver.observe(this.element),_(this.nodeListElement,"click","div.wb-row",(t=>{const i=ue.getEventInfo(t),s=i.node,n=t;if(!1===this._callEvent("click",{event:t,node:s,info:i}))return this.lastClickTime=Date.now(),!1;if(s){if(n.ctrlKey)return void s.toggleSelected();const r=this.getOption("edit.trigger"),o=this.getOption("edit.slowClickDelay");r.indexOf("clickActive")>=0&&"title"===i.region&&s.isActive()&&(!o||Date.now()-this.lastClickTime<o)&&this._callMethod("edit.startEditTitle",s),i.colIdx>=0?s.setActive(!0,{colIdx:i.colIdx,event:t}):s.setActive(!0,{event:t}),i.region===T.expander?s.setExpanded(!s.isExpanded(),{scrollIntoView:!1!==e.scrollIntoViewOnExpandClick}):i.region===T.checkbox&&s.toggleSelected()}this.lastClickTime=Date.now()})),_(this.nodeListElement,"dblclick","div.wb-row",(e=>{const t=ue.getEventInfo(e),i=t.node;if(!1===this._callEvent("dblclick",{event:e,node:i,info:t}))return!1;i&&0===t.colIdx&&i.isExpandable()&&(this._callMethod("edit._stopEditTitle"),i.setExpanded(!i.isExpanded()))})),_(this.element,"keydown",(e=>{const t=ue.getEventInfo(e),i=b(e),s=t.node||this.getFocusNode();this._callHook("onKeyEvent",{event:e,node:s,info:t,eventName:i})})),_(this.element,"focusin focusout",(e=>{const i="focusin"===e.type,s=ue.getNode(e);this._callEvent("focus",{flag:i,event:e}),i&&this.isRowNav()&&!this.isEditing()&&(t.navigationModeOption===M.row?null==s||s.setActive():this.setCellNav()),i||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof ue)return e;if(e instanceof de)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(const t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return o(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}get iconMap(){const e=this.options.iconMap;return"string"==typeof e?Y[e]:e}static getNode(e){if(!e)return null;if(e instanceof de)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}*[Symbol.iterator](){yield*this.root}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(const e of this.extensionList)e.init()}_registerNode(e){const t=e.key;o(null!=t&&!this.keyMap.has(t),`Missing or duplicate key: '${t}'.`),this.keyMap.set(t,e);const i=e.refKey;if(i){const t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,e.removeMarkup()}_callHook(e,t={}){let i;const s=y({},{tree:this,options:this.options,result:void 0},t);for(const t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,y({type:e,tree:this,util:this._util},t))}_getNodeByRowIdx(e){let t=null;return this.visitRows((i=>{if(i._rowIdx===e)return t=i,!1})),t}getTopmostVpNode(e=!0){const t=this.element.scrollTop;let i;return i=e?Math.ceil((t-1)/G):Math.floor(t/G),this._getNodeByRowIdx(i)}getLowestVpNode(e=!0){const t=this.element,i=this.headerElement.clientHeight,s=t.scrollTop,n=t.clientHeight-i;let r;return r=e?Math.floor((s+n)/G)-1:Math.ceil((s+n)/G)-1,r=Math.min(r,this.count(!0)-1),this._getNodeByRowIdx(r)}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof de?s=t:(s=this.getActiveNode(),o(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:a(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.treeRowCount=0,this.activeNode=null,this.focusNode=null,this.update(D.structure)}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(e.indexOf(".")>=0){const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}else switch(this.options[e]=t,e){case"checkbox":this.update(D.any);break;case"enabled":this.setEnabled(!!t);break;case"fixedCol":this.element.classList.toggle("wb-fixed-col",!!t)}}hasFocus(){return this.element.contains(document.activeElement)}hasHeader(){const e=this.options.header;return this.isGrid()?!1!==e:!!e}runWithDeferredUpdate(e,t=null){try{this.enableUpdate(!1);const t=e();return o(!(t instanceof Promise)),t}finally{this.enableUpdate(!0)}}async expandAll(e=!0,t){await this.root.expandAll(e,t)}selectAll(e=!0){return this.root.setSelected(e,{propagateDown:!0})}toggleSelect(){this.selectAll(this.root._anySelectable())}getSelectedNodes(e=!1){return this.root.getSelectedNodes(e)}_selectRange(e){this.logDebug("_selectRange",e),a("Not yet implemented.")}count(e=!1){return e?this.treeRowCount:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findKey(e){return this.keyMap.get(e)||null}findNextNode(e,t){let i=null;const s=this.getFirstChild(),n="string"==typeof e?function(e){e=c(e);const t=new RegExp("^"+e,"i");return function(e){return t.test(e.title)}}(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null;const n=Math.floor(this.listContainerElement.clientHeight/G);switch(t){case"parent":case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((e=>{if(e.isVisible())return s=e,!1}));break;case"last":this.visit((e=>{e.isVisible()&&(s=e)}));break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":{const t=this.getLowestVpNode();s=e._rowIdx<t._rowIdx?t:this._getNextNodeInView(e,n)}break;case"pageUp":if(0===e._rowIdx)s=e;else{const t=this.getTopmostVpNode();s=e._rowIdx>t._rowIdx?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}*format_iter(e,t){yield*this.root.format_iter(e,t)}format(e,t){return this.root.format(e,t)}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){const t=e.target,i=t.classList,s=t.closest("span.wb-col"),n=ue.getNode(t),r=n?n.tree:ue.getTree(e),o={event:e,canonicalName:b(e),tree:r,node:n,region:T.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))o.region=T.title;else if(i.contains("wb-expander"))o.region=n.isExpandable()?T.expander:T.prefix;else if(i.contains("wb-checkbox"))o.region=T.checkbox;else if(i.contains("wb-icon"))o.region=T.icon;else if(i.contains("wb-node"))o.region=T.title;else if(s){o.region=T.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);o.colIdx=e}else{if(!i.contains("wb-row"))return"mousemove"===e.type||e instanceof KeyboardEvent||null==r||r.logWarn("getEventInfo(): not found",e,o),o;o.region=T.title}return-1===o.colIdx&&(o.colIdx=0),o.colDef=null==r?void 0:r.columns[o.colIdx],null!=o.colDef&&(o.colId=o.colDef.id),o}toString(){return`Wunderbaum<'${this.id}'>`}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){let e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&console.log(this.toString(),...e)}logError(...e){this.options.debugLevel>=1&&console.error(this.toString(),...e)}logInfo(...e){this.options.debugLevel>=3&&console.info(this.toString(),...e)}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&console.warn(this.toString(),...e)}scrollTo(e){let t,i;e instanceof de?t=e:(i=e,t=i.node),o(t&&null!=t._rowIdx);const s=this.element,n=this.headerElement.clientHeight,r=s.scrollTop,l=s.clientHeight,a=t._rowIdx*G+n,d=n,c=a-r,h=c+G,u=null==i?void 0:i.topNode;let p=null;c>=d?h<=l||(p=a+G-l+2):p=a-d-2,null!=p&&(this.log(`scrollTo(${a}): ${r} => ${p}`),s.scrollTop=p,u&&this.scrollTo(u))}scrollToHorz(){const e=this.columns[0]._widthPx,t=this.element.clientWidth,i=this.element.scrollLeft,s=this.getActiveColElem(),n=Number.parseInt(null==s?void 0:s.style.left,10),r=n+Number.parseInt(null==s?void 0:s.style.width,10);let o=i;n-i<e?o=n-e:r-i>t&&(o=r-t),o=Math.max(0,o),this.log(`scrollToHorz(${this.activeColIdx}): ${n}..${r}, fixedOfs=${e}, vpWidth=${t}, curLeft=${i} -> ${o}`),this.element.scrollLeft=o}setColumn(e){var t;if(o(this.isCellNav()),o(0<=e&&e<this.columns.length),this.activeColIdx=e,this.hasHeader())for(const t of this.headerElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}null===(t=this.activeNode)||void 0===t||t.update(D.status);for(const t of this.nodeListElement.children){let i=0;for(const s of t.children)s.classList.toggle("wb-active",i++===e)}this.scrollToHorz()}setActiveNode(e,t=!0,i){var s;null===(s=this.findKey(e))||void 0===s||s.setActive(t,i)}setFocus(e=!0){e?this.element.focus():this.element.blur()}update(e,t,i){if(this._disableUpdateCount)return void this._disableUpdateIgnoreCount++;t instanceof de||(i=t,t=null);const s=!!k(i,"immediate"),n=L,r=this.pendingChangeTypes;switch(e){case D.any:case D.colStructure:r.add(n.header),r.add(n.clearMarkup),r.add(n.redraw),r.add(n.scroll);break;case D.resize:r.add(n.header),r.add(n.redraw);break;case D.structure:r.add(n.redraw);break;case D.scroll:r.add(n.scroll);break;case D.row:case D.data:case D.status:o(t,`Option '${e}' requires a node.`),t._rowElem&&t._render({change:e});break;default:a(`Invalid change type '${e}'.`)}if(e===D.colStructure){const e=this.isGrid();this.element.classList.toggle("wb-grid",e),!e&&this.isCellNav()&&this.setCellNav(!1)}r.size>0&&(s?this._updateViewportImmediately():this._updateViewportThrottled())}setEnabled(e=!0){const t=this.enabled;return this.enabled=!!e,this.element.classList.toggle("wb-disabled",!e),t}isEnabled(){return this.enabled}isGrid(){return this.columns&&this.columns.length>1}isCellNav(){return!!this._cellNavMode}isRowNav(){return!this._cellNavMode}setCellNav(e=!0){var t;const i=this._cellNavMode;this._cellNavMode=!!e,e&&!i&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",e),null===(t=this.activeNode)||void 0===t||t.update(D.status)}setNavigationOption(e,t=!1){if(this.isGrid()||e===M.row)switch(this.options.navigationModeOption=e,e){case M.cell:this.setCellNav(!0);break;case M.row:this.setCellNav(!1);break;case M.startCell:t&&this.setCellNav(!0);break;case M.startRow:t&&this.setCellNav(!1);break;default:a(`Invalid mode '${e}'.`)}else this.logWarn("Plain trees only support row navigation mode.")}setStatus(e,t){return this.root.setStatus(e,t)}setTypes(e,t=!0){o(x(e)),t?this.types=e:y(this.types,e);for(const e of Object.values(this.types))e.classes&&(e.classes=N(e.classes))}sortChildren(e=ee,t=!1){this.root.sortChildren(e,t)}toDictArray(e){var t;return null!==(t=this.root.toDict(!0,e).children)&&void 0!==t?t:[]}_updateColumnWidths(){const e=this.element.clientWidth,t=this.columns,i=t[0];let s=0,n=0,r=0,o=!1;if("*"!==i.id)throw new Error(`First column must have id '*': got '${i.id}'.`);this._columnsById={};for(const e of t){this._columnsById[e.id]=e;const t=e.width;if("*"===e.id&&e!==i)throw new Error(`Column id '*' must be defined only once: '${e.title}'.`);if(t&&"*"!==t)if("number"==typeof t)e._weight=t,n+=t;else if("string"==typeof t&&t.endsWith("px")){e._weight=0;const i=parseFloat(t.slice(0,-2));e._widthPx!=i&&(o=!0,e._widthPx=i),r+=i}else a(`Invalid column width: ${t} (expected string ending with 'px' or number, e.g. "<num>px" or <int>).`);else e._weight=1,n+=1}const l=Math.max(0,e-r);let d=0;for(const e of t){let t;if(e._weight){const i=e.minWidth;t="number"==typeof i?i:"string"==typeof i&&i.endsWith("px")?parseFloat(i.slice(0,-2)):4;const s=Math.max(t,l*e._weight/n);e._widthPx!=s&&(o=!0,e._widthPx=s)}e._ofsPx=d,d+=e._widthPx}t[t.length-1]._widthPx-=0,s=d-0;const c=`${s}px`;return this.headerElement.style.width=c,this.listContainerElement.style.width=c,o}_renderHeaderMarkup(){o(this.headerElement);const e=this.hasHeader();if(p(this.headerElement,e),!e)return;const t=this.columns.length,i=this.headerElement.querySelector(".wb-row");o(i),i.innerHTML="<span class='wb-col'></span>".repeat(t);for(let e=0;e<t;e++){const s=this.columns[e],n=i.children[e];n.style.left=s._ofsPx+"px",n.style.width=s._widthPx+"px","string"==typeof s.headerClasses?s.headerClasses&&n.classList.add(...s.headerClasses.split(" ")):s.classes&&n.classList.add(...s.classes.split(" "));const r=d(s.title||s.id);let o="";s.tooltip&&(o=h(s.tooltip),o=` title="${o}"`);let l="";e<t-1&&(l='<span class="wb-col-resizer"></span>'),n.innerHTML=`<span class="wb-col-title"${o}>${r}</span>${l}`,this.isCellNav()&&n.classList.toggle("wb-active",e===this.activeColIdx)}}updatePendingModifications(){this.pendingChangeTypes.size>0&&this._updateViewportImmediately()}_updateViewportImmediately(){var e;if(this._disableUpdateCount)return this.log(`_updateViewportImmediately() IGNORED (disable level: ${this._disableUpdateCount})`),void this._disableUpdateIgnoreCount++;const t=L,i=new Set(this.pendingChangeTypes);this.pendingChangeTypes.clear();if(i.has(t.scroll)&&1===i.size)this._updateRows({newNodesOnly:!0});else{if(this.log("_updateViewportImmediately():",i),!1!==this.options.adjustHeight){let e=this.listContainerElement.clientHeight;const t=this.headerElement.clientHeight,i=this.element.clientHeight-t-1;Math.abs(e-i)>1&&(this.listContainerElement.style.height=i+"px",e=i)}i.has(t.clearMarkup)&&this.visit((e=>{e.removeMarkup()})),i.has(t.header)&&(this._updateColumnWidths(),this._renderHeaderMarkup()),this._updateRows()}if(this.options.connectTopBreadcrumb){let t=null===(e=this.getTopmostVpNode(!0))||void 0===e?void 0:e.getPath(!1,"title"," > ");t=t?t+" >":"",this.options.connectTopBreadcrumb.textContent=t}this._callEvent("update")}_updateRows(e){const t=!!(e=Object.assign({newNodesOnly:!1},e)).newNodesOnly,i=this.element.clientHeight,s=this.element.scrollTop;let n=Math.max(0,s/22-5);n=Math.floor(n),n%2&&n--;let r=Math.max(0,(s+i)/22+5);r=Math.ceil(r);const o=new Set;this.nodeListElement.childNodes.forEach((e=>{const t=e;o.add(t._wb_node)}));let l=0,a=0,d=!1,c="first";this.visitRows((function(e){const i=e._rowElem;e._rowIdx!==l&&(e._rowIdx=l,d=!0),l<n||l>r?i&&(c=i):i&&t?(o.delete(e),i.style.top=l*G+"px",c=i):(o.delete(e),i&&(i.style.top=l*G+"px"),e._render({top:a,after:c}),c=e._rowElem),l++,a+=22})),this.treeRowCount=l;for(const e of o)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=`${a}px`,d}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,l,a,d=0,c=!1===(t=t||{}).includeSelf,h=t.start||this.root.children[0];const u=!!t.includeHidden,p=!u&&"hide"===this.filterMode;for(n=h.parent;n;){for(l=n.children,s=l.indexOf(h)+d,o(s>=0,`Could not find ${h} in parent's children: ${n}`),i=s;i<l.length;i++){if(h=l[i],h===a)return!1;if(!p||h.statusNodeType||h.match||h.subMatchCount){if(!c&&!1===e(h))return!1;if(c=!1,h.children&&h.children.length&&(u||h.expanded)&&(r=h.visit((t=>t!==a&&(!p||t.match||t.subMatchCount?!1!==e(t)&&(u||!t.children||t.expanded?void 0:"skip"):"skip")),!1),!1===r))return!1}}h=n,n=n.parent,d=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),o(t.start,"`wrap` option requires `start`"),a=t.start,t.wrap=!1,n=this.root,d=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=t.start||this.root.children[0];const o=!!t.includeHidden;if(!1!==t.includeSelf&&!1===e(r))return!1;for(;;){if(n=r.parent,i=n.children,i[0]===r){if(r=n,!r.parent)break;i=n.children}else for(s=i.indexOf(r),r=i[s-1];(o||r.expanded)&&r.children&&r.children.length;)i=r.children,n=r,r=i[i.length-1];if((o||r.isVisible())&&!1===e(r))return!1}return!0}load(e){return this.clear(),this.root.load(e)}enableUpdate(e){e?(o(this._disableUpdateCount>0,"enableUpdate(true) was called too often"),this._disableUpdateCount--,0===this._disableUpdateCount&&(this.logDebug(`enableUpdate(): active again. Re-painting to catch up with ${this._disableUpdateIgnoreCount} ignored update requests...`),this._disableUpdateIgnoreCount=0,this.update(D.any,{immediate:!0}))):this._disableUpdateCount++}filterNodes(e,t){return this.extensions.filter.filterNodes(e,t)}filterBranches(e,t){return this.extensions.filter.filterBranches(e,t)}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}ue.sequence=0,ue.version="v0.5.4",ue.util=O,e.Wunderbaum=ue}));
87
87
  //# sourceMappingURL=wunderbaum.umd.min.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wunderbaum",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "title": "A treegrid control.",
5
5
  "description": "JavaScript tree/grid/treegrid control.",
6
6
  "homepage": "https://github.com/mar10/wunderbaum",