@gip-recia/js-tree
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -1,13 +0,21 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).esupJsTree={})}(this,(function(t){"use strict"; | ||
/** | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.esupJsTree = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
/** | ||
* @license | ||
* Copyright 2019 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/const e=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),n=new Map;class s{constructor(t,e){if(this._$cssResult$=!0,e!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=n.get(this.cssText);return e&&void 0===t&&(n.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const o=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",i))(e)})(t):t | ||
/** | ||
*/ | ||
const t$1=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e$2=Symbol(),n$3=new Map;class s$3{constructor(t,n){if(this._$cssResult$=!0,n!==e$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t;}get styleSheet(){let e=n$3.get(this.cssText);return t$1&&void 0===e&&(n$3.set(this.cssText,e=new CSSStyleSheet),e.replaceSync(this.cssText)),e}toString(){return this.cssText}}const o$3=t=>new s$3("string"==typeof t?t:t+"",e$2),r$2=(t,...n)=>{const o=1===t.length?t[0]:n.reduce(((e,n,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[s+1]),t[0]);return new s$3(o,e$2)},i$1=(e,n)=>{t$1?e.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((t=>{const n=document.createElement("style"),s=window.litNonce;void 0!==s&&n.setAttribute("nonce",s),n.textContent=t.cssText,e.appendChild(n);}));},S$1=t$1?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return o$3(e)})(t):t; | ||
/** | ||
* @license | ||
* Copyright 2017 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/;var r;const l=window.trustedTypes,a=l?l.emptyScript:"",d=window.reactiveElementPolyfillSupport,h={toAttribute(t,e){switch(e){case Boolean:t=t?a:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},c=(t,e)=>e!==t&&(e==e||t==t),p={attribute:!0,type:String,converter:h,reflect:!1,hasChanged:c};class u extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const n=this._$Eh(i,e);void 0!==n&&(this._$Eu.set(n,i),t.push(n))})),t}static createProperty(t,e=p){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const s=this[t];this[e]=n,this.requestUpdate(t,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(o(t))}else void 0!==t&&e.push(o(t));return e}static _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Eg)&&void 0!==e?e:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$Eg)||void 0===e||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const i=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,i)=>{e?t.adoptedStyleSheets=i.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):i.forEach((e=>{const i=document.createElement("style"),n=window.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,t.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ES(t,e,i=p){var n,s;const o=this.constructor._$Eh(t,i);if(void 0!==o&&!0===i.reflect){const r=(null!==(s=null===(n=i.converter)||void 0===n?void 0:n.toAttribute)&&void 0!==s?s:h.toAttribute)(e,i.type);this._$Ei=t,null==r?this.removeAttribute(o):this.setAttribute(o,r),this._$Ei=null}}_$AK(t,e){var i,n,s;const o=this.constructor,r=o._$Eu.get(t);if(void 0!==r&&this._$Ei!==r){const t=o.getPropertyOptions(r),l=t.converter,a=null!==(s=null!==(n=null===(i=l)||void 0===i?void 0:i.fromAttribute)&&void 0!==n?n:"function"==typeof l?l:null)&&void 0!==s?s:h.fromAttribute;this._$Ei=r,this[r]=a(e,t.type),this._$Ei=null}}requestUpdate(t,e,i){let n=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||c)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):n=!1),!this.isUpdatePending&&n&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$EU()}catch(t){throw e=!1,this._$EU(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Eg)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$ES(e,this[e],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}} | ||
/** | ||
*/var s$2;const e$1=window.trustedTypes,r$1=e$1?e$1.emptyScript:"",h$1=window.reactiveElementPolyfillSupport,o$2={toAttribute(t,i){switch(i){case Boolean:t=t?r$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t);}catch(t){s=null;}}return s}},n$2=(t,i)=>i!==t&&(i==i||t==t),l$2={attribute:!0,type:String,converter:o$2,reflect:!1,hasChanged:n$2};class a$1 extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o();}static addInitializer(t){var i;null!==(i=this.l)&&void 0!==i||(this.l=[]),this.l.push(t);}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,s)=>{const e=this._$Eh(s,i);void 0!==e&&(this._$Eu.set(e,s),t.push(e));})),t}static createProperty(t,i=l$2){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e);}}static getPropertyDescriptor(t,i,s){return {get(){return this[i]},set(e){const r=this[t];this[i]=e,this.requestUpdate(t,r,s);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||l$2}static finalize(){if(this.hasOwnProperty("finalized"))return !1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const s of i)this.createProperty(s,t[s]);}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(i){const s=[];if(Array.isArray(i)){const e=new Set(i.flat(1/0).reverse());for(const i of e)s.unshift(S$1(i));}else void 0!==i&&s.push(S$1(i));return s}static _$Eh(t,i){const s=i.attribute;return !1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)));}addController(t){var i,s;(null!==(i=this._$Eg)&&void 0!==i?i:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.call(t));}removeController(t){var i;null===(i=this._$Eg)||void 0===i||i.splice(this._$Eg.indexOf(t)>>>0,1);}_$Em(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Et.set(i,this[i]),delete this[i]);}));}createRenderRoot(){var t;const s=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return i$1(s,this.constructor.elementStyles),s}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}));}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}));}attributeChangedCallback(t,i,s){this._$AK(t,s);}_$ES(t,i,s=l$2){var e,r;const h=this.constructor._$Eh(t,s);if(void 0!==h&&!0===s.reflect){const n=(null!==(r=null===(e=s.converter)||void 0===e?void 0:e.toAttribute)&&void 0!==r?r:o$2.toAttribute)(i,s.type);this._$Ei=t,null==n?this.removeAttribute(h):this.setAttribute(h,n),this._$Ei=null;}}_$AK(t,i){var s,e,r;const h=this.constructor,n=h._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=h.getPropertyOptions(n),l=t.converter,a=null!==(r=null!==(e=null===(s=l)||void 0===s?void 0:s.fromAttribute)&&void 0!==e?e:"function"==typeof l?l:null)&&void 0!==r?r:o$2.fromAttribute;this._$Ei=n,this[n]=a(i,t.type),this._$Ei=null;}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||n$2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):e=!1),!this.isUpdatePending&&e&&(this._$Ep=this._$E_());}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,i)=>this[i]=t)),this._$Et=void 0);let i=!1;const s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(s)):this._$EU();}catch(t){throw i=!1,this._$EU(),t}i&&this._$AE(s);}willUpdate(t){}_$AE(t){var i;null===(i=this._$Eg)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$EU(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return !0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$ES(i,this[i],t))),this._$EC=void 0),this._$EU();}updated(t){}firstUpdated(t){}}a$1.finalized=!0,a$1.elementProperties=new Map,a$1.elementStyles=[],a$1.shadowRootOptions={mode:"open"},null==h$1||h$1({ReactiveElement:a$1}),(null!==(s$2=globalThis.reactiveElementVersions)&&void 0!==s$2?s$2:globalThis.reactiveElementVersions=[]).push("1.3.0"); | ||
/** | ||
* @license | ||
@@ -17,8 +25,879 @@ * Copyright 2017 Google LLC | ||
*/ | ||
var f;u.finalized=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:u}),(null!==(r=globalThis.reactiveElementVersions)&&void 0!==r?r:globalThis.reactiveElementVersions=[]).push("1.3.0");const v=globalThis.trustedTypes,m=v?v.createPolicy("lit-html",{createHTML:t=>t}):void 0,_=`lit$${(Math.random()+"").slice(9)}$`,g="?"+_,$=`<${g}>`,y=document,b=(t="")=>y.createComment(t),C=t=>null===t||"object"!=typeof t&&"function"!=typeof t,A=Array.isArray,w=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,E=/-->/g,x=/>/g,S=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,P=/'/g,U=/"/g,k=/^(?:script|style|textarea|title)$/i,D=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),H=Symbol.for("lit-noChange"),N=Symbol.for("lit-nothing"),T=new WeakMap,O=y.createTreeWalker(y,129,null,!1),L=(t,e)=>{const i=t.length-1,n=[];let s,o=2===e?"<svg>":"",r=w;for(let e=0;e<i;e++){const i=t[e];let l,a,d=-1,h=0;for(;h<i.length&&(r.lastIndex=h,a=r.exec(i),null!==a);)h=r.lastIndex,r===w?"!--"===a[1]?r=E:void 0!==a[1]?r=x:void 0!==a[2]?(k.test(a[2])&&(s=RegExp("</"+a[2],"g")),r=S):void 0!==a[3]&&(r=S):r===S?">"===a[0]?(r=null!=s?s:w,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,l=a[1],r=void 0===a[3]?S:'"'===a[3]?U:P):r===U||r===P?r=S:r===E||r===x?r=w:(r=S,s=void 0);const c=r===S&&t[e+1].startsWith("/>")?" ":"";o+=r===w?i+$:d>=0?(n.push(l),i.slice(0,d)+"$lit$"+i.slice(d)+_+c):i+_+(-2===d?(n.push(void 0),e):c)}const l=o+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==m?m.createHTML(l):l,n]};class R{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let s=0,o=0;const r=t.length-1,l=this.parts,[a,d]=L(t,e);if(this.el=R.createElement(a,i),O.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(n=O.nextNode())&&l.length<r;){if(1===n.nodeType){if(n.hasAttributes()){const t=[];for(const e of n.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(_)){const i=d[o++];if(t.push(e),void 0!==i){const t=n.getAttribute(i.toLowerCase()+"$lit$").split(_),e=/([.?@])?(.*)/.exec(i);l.push({type:1,index:s,name:e[2],strings:t,ctor:"."===e[1]?q:"?"===e[1]?V:"@"===e[1]?z:I})}else l.push({type:6,index:s})}for(const e of t)n.removeAttribute(e)}if(k.test(n.tagName)){const t=n.textContent.split(_),e=t.length-1;if(e>0){n.textContent=v?v.emptyScript:"";for(let i=0;i<e;i++)n.append(t[i],b()),O.nextNode(),l.push({type:2,index:++s});n.append(t[e],b())}}}else if(8===n.nodeType)if(n.data===g)l.push({type:2,index:s});else{let t=-1;for(;-1!==(t=n.data.indexOf(_,t+1));)l.push({type:7,index:s}),t+=_.length-1}s++}}static createElement(t,e){const i=y.createElement("template");return i.innerHTML=t,i}}function M(t,e,i=t,n){var s,o,r,l;if(e===H)return e;let a=void 0!==n?null===(s=i._$Cl)||void 0===s?void 0:s[n]:i._$Cu;const d=C(e)?void 0:e._$litDirective$;return(null==a?void 0:a.constructor)!==d&&(null===(o=null==a?void 0:a._$AO)||void 0===o||o.call(a,!1),void 0===d?a=void 0:(a=new d(t),a._$AT(t,i,n)),void 0!==n?(null!==(r=(l=i)._$Cl)&&void 0!==r?r:l._$Cl=[])[n]=a:i._$Cu=a),void 0!==a&&(e=M(t,a._$AS(t,e.values),a,n)),e}class F{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:n}=this._$AD,s=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:y).importNode(i,!0);O.currentNode=s;let o=O.nextNode(),r=0,l=0,a=n[0];for(;void 0!==a;){if(r===a.index){let e;2===a.type?e=new B(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new K(o,this,t)),this.v.push(e),a=n[++l]}r!==(null==a?void 0:a.index)&&(o=O.nextNode(),r++)}return s}m(t){let e=0;for(const i of this.v)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class B{constructor(t,e,i,n){var s;this.type=2,this._$AH=N,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cg=null===(s=null==n?void 0:n.isConnected)||void 0===s||s}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=M(this,t,e),C(t)?t===N||null==t||""===t?(this._$AH!==N&&this._$AR(),this._$AH=N):t!==this._$AH&&t!==H&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var e;return A(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(t)?this.S(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==N&&C(this._$AH)?this._$AA.nextSibling.data=t:this.k(y.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:n}=t,s="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=R.createElement(n.h,this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===s)this._$AH.m(i);else{const t=new F(s,this),e=t.p(this.options);t.m(i),this.k(e),this._$AH=t}}_$AC(t){let e=T.get(t.strings);return void 0===e&&T.set(t.strings,e=new R(t)),e}S(t){A(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const s of t)n===e.length?e.push(i=new B(this.A(b()),this.A(b()),this,this.options)):i=e[n],i._$AI(s),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cg=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class I{constructor(t,e,i,n,s){this.type=1,this._$AH=N,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=s,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=N}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,n){const s=this.strings;let o=!1;if(void 0===s)t=M(this,t,e,0),o=!C(t)||t!==this._$AH&&t!==H,o&&(this._$AH=t);else{const n=t;let r,l;for(t=s[0],r=0;r<s.length-1;r++)l=M(this,n[i+r],e,r),l===H&&(l=this._$AH[r]),o||(o=!C(l)||l!==this._$AH[r]),l===N?t=N:t!==N&&(t+=(null!=l?l:"")+s[r+1]),this._$AH[r]=l}o&&!n&&this.C(t)}C(t){t===N?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class q extends I{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===N?void 0:t}}const j=v?v.emptyScript:"";class V extends I{constructor(){super(...arguments),this.type=4}C(t){t&&t!==N?this.element.setAttribute(this.name,j):this.element.removeAttribute(this.name)}}class z extends I{constructor(t,e,i,n,s){super(t,e,i,n,s),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=M(this,t,e,0))&&void 0!==i?i:N)===H)return;const n=this._$AH,s=t===N&&n!==N||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==N&&(n===N||s);s&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class K{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t)}}const W=window.litHtmlPolyfillSupport; | ||
/** | ||
var t;const i=globalThis.trustedTypes,s$1=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e=`lit$${(Math.random()+"").slice(9)}$`,o$1="?"+e,n$1=`<${o$1}>`,l$1=document,h=(t="")=>l$1.createComment(t),r=t=>null===t||"object"!=typeof t&&"function"!=typeof t,d=Array.isArray,u=t=>{var i;return d(t)||"function"==typeof(null===(i=t)||void 0===i?void 0:i[Symbol.iterator])},c=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,a=/>/g,f=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,_=/'/g,m=/"/g,g=/^(?:script|style|textarea|title)$/i,p=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),$=p(1),b=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),T=new WeakMap,x=(t,i,s)=>{var e,o;const n=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:i;let l=n._$litPart$;if(void 0===l){const t=null!==(o=null==s?void 0:s.renderBefore)&&void 0!==o?o:null;n._$litPart$=l=new N(i.insertBefore(h(),t),t,void 0,null!=s?s:{});}return l._$AI(t),l},A=l$1.createTreeWalker(l$1,129,null,!1),C=(t,i)=>{const o=t.length-1,l=[];let h,r=2===i?"<svg>":"",d=c;for(let i=0;i<o;i++){const s=t[i];let o,u,p=-1,$=0;for(;$<s.length&&(d.lastIndex=$,u=d.exec(s),null!==u);)$=d.lastIndex,d===c?"!--"===u[1]?d=v:void 0!==u[1]?d=a:void 0!==u[2]?(g.test(u[2])&&(h=RegExp("</"+u[2],"g")),d=f):void 0!==u[3]&&(d=f):d===f?">"===u[0]?(d=null!=h?h:c,p=-1):void 0===u[1]?p=-2:(p=d.lastIndex-u[2].length,o=u[1],d=void 0===u[3]?f:'"'===u[3]?m:_):d===m||d===_?d=f:d===v||d===a?d=c:(d=f,h=void 0);const y=d===f&&t[i+1].startsWith("/>")?" ":"";r+=d===c?s+n$1:p>=0?(l.push(o),s.slice(0,p)+"$lit$"+s.slice(p)+e+y):s+e+(-2===p?(l.push(void 0),i):y);}const u=r+(t[o]||"<?>")+(2===i?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return [void 0!==s$1?s$1.createHTML(u):u,l]};class E{constructor({strings:t,_$litType$:s},n){let l;this.parts=[];let r=0,d=0;const u=t.length-1,c=this.parts,[v,a]=C(t,s);if(this.el=E.createElement(v,n),A.currentNode=this.el.content,2===s){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes);}for(;null!==(l=A.nextNode())&&c.length<u;){if(1===l.nodeType){if(l.hasAttributes()){const t=[];for(const i of l.getAttributeNames())if(i.endsWith("$lit$")||i.startsWith(e)){const s=a[d++];if(t.push(i),void 0!==s){const t=l.getAttribute(s.toLowerCase()+"$lit$").split(e),i=/([.?@])?(.*)/.exec(s);c.push({type:1,index:r,name:i[2],strings:t,ctor:"."===i[1]?M:"?"===i[1]?H:"@"===i[1]?I:S});}else c.push({type:6,index:r});}for(const i of t)l.removeAttribute(i);}if(g.test(l.tagName)){const t=l.textContent.split(e),s=t.length-1;if(s>0){l.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)l.append(t[i],h()),A.nextNode(),c.push({type:2,index:++r});l.append(t[s],h());}}}else if(8===l.nodeType)if(l.data===o$1)c.push({type:2,index:r});else {let t=-1;for(;-1!==(t=l.data.indexOf(e,t+1));)c.push({type:7,index:r}),t+=e.length-1;}r++;}}static createElement(t,i){const s=l$1.createElement("template");return s.innerHTML=t,s}}function P(t,i,s=t,e){var o,n,l,h;if(i===b)return i;let d=void 0!==e?null===(o=s._$Cl)||void 0===o?void 0:o[e]:s._$Cu;const u=r(i)?void 0:i._$litDirective$;return (null==d?void 0:d.constructor)!==u&&(null===(n=null==d?void 0:d._$AO)||void 0===n||n.call(d,!1),void 0===u?d=void 0:(d=new u(t),d._$AT(t,s,e)),void 0!==e?(null!==(l=(h=s)._$Cl)&&void 0!==l?l:h._$Cl=[])[e]=d:s._$Cu=d),void 0!==d&&(i=P(t,d._$AS(t,i.values),d,e)),i}class V{constructor(t,i){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var i;const{el:{content:s},parts:e}=this._$AD,o=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:l$1).importNode(s,!0);A.currentNode=o;let n=A.nextNode(),h=0,r=0,d=e[0];for(;void 0!==d;){if(h===d.index){let i;2===d.type?i=new N(n,n.nextSibling,this,t):1===d.type?i=new d.ctor(n,d.name,d.strings,this,t):6===d.type&&(i=new L(n,this,t)),this.v.push(i),d=e[++r];}h!==(null==d?void 0:d.index)&&(n=A.nextNode(),h++);}return o}m(t){let i=0;for(const s of this.v)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class N{constructor(t,i,s,e){var o;this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cg=null===(o=null==e?void 0:e.isConnected)||void 0===o||o;}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=P(this,t,i),r(t)?t===w||null==t||""===t?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==b&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):u(t)?this.S(t):this.$(t);}A(t,i=this._$AB){return this._$AA.parentNode.insertBefore(t,i)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t));}$(t){this._$AH!==w&&r(this._$AH)?this._$AA.nextSibling.data=t:this.k(l$1.createTextNode(t)),this._$AH=t;}T(t){var i;const{values:s,_$litType$:e}=t,o="number"==typeof e?this._$AC(t):(void 0===e.el&&(e.el=E.createElement(e.h,this.options)),e);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===o)this._$AH.m(s);else {const t=new V(o,this),i=t.p(this.options);t.m(s),this.k(i),this._$AH=t;}}_$AC(t){let i=T.get(t.strings);return void 0===i&&T.set(t.strings,i=new E(t)),i}S(t){d(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const o of t)e===i.length?i.push(s=new N(this.A(h()),this.A(h()),this,this.options)):s=i[e],s._$AI(o),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){var i;void 0===this._$AM&&(this._$Cg=t,null===(i=this._$AP)||void 0===i||i.call(this,t));}}class S{constructor(t,i,s,e,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=o,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=w;}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const o=this.strings;let n=!1;if(void 0===o)t=P(this,t,i,0),n=!r(t)||t!==this._$AH&&t!==b,n&&(this._$AH=t);else {const e=t;let l,h;for(t=o[0],l=0;l<o.length-1;l++)h=P(this,e[s+l],i,l),h===b&&(h=this._$AH[l]),n||(n=!r(h)||h!==this._$AH[l]),h===w?t=w:t!==w&&(t+=(null!=h?h:"")+o[l+1]),this._$AH[l]=h;}n&&!e&&this.C(t);}C(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"");}}class M extends S{constructor(){super(...arguments),this.type=3;}C(t){this.element[this.name]=t===w?void 0:t;}}const k=i?i.emptyScript:"";class H extends S{constructor(){super(...arguments),this.type=4;}C(t){t&&t!==w?this.element.setAttribute(this.name,k):this.element.removeAttribute(this.name);}}class I extends S{constructor(t,i,s,e,o){super(t,i,s,e,o),this.type=5;}_$AI(t,i=this){var s;if((t=null!==(s=P(this,t,i,0))&&void 0!==s?s:w)===b)return;const e=this._$AH,o=t===w&&e!==w||t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive,n=t!==w&&(e===w||o);o&&this.element.removeEventListener(this.name,this,e),n&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t);}}class L{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){P(this,t);}}const z=window.litHtmlPolyfillSupport;null==z||z(E,N),(null!==(t=globalThis.litHtmlVersions)&&void 0!==t?t:globalThis.litHtmlVersions=[]).push("2.2.0"); | ||
/** | ||
* @license | ||
* Copyright 2017 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/var l,o;class s extends a$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0;}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=x(i,this.renderRoot,this.renderOptions);}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0);}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1);}render(){return b}}s.finalized=!0,s._$litElement$=!0,null===(l=globalThis.litElementHydrateSupport)||void 0===l||l.call(globalThis,{LitElement:s});const n=globalThis.litElementPolyfillSupport;null==n||n({LitElement:s});(null!==(o=globalThis.litElementVersions)&&void 0!==o?o:globalThis.litElementVersions=[]).push("3.2.0"); | ||
const jsTreeStyle = r$2` | ||
/* tree */ | ||
.root-tree { | ||
padding-left: 0; | ||
margin-left: 1px; | ||
margin-right: 1px; | ||
--min-dimension: var(--min-clickable-dimension, 24px); | ||
} | ||
.root-tree li { | ||
list-style-type: none; | ||
} | ||
.root-tree .row-data:focus, | ||
.root-tree .row-data:hover { | ||
color: var(--hover-text-color, black); | ||
} | ||
.root-tree .row-data.jstree-clicked, | ||
.root-tree .row-data.jstree-clicked span { | ||
background-color: var(--selected-background-color, transparent); | ||
color: var(--selected-text-color, black); | ||
} | ||
.root-tree .row, | ||
.root-tree .row-data { | ||
display: inline-block; | ||
min-height: var(--min-dimension); | ||
min-width: var(--min-dimension); | ||
} | ||
.root-tree .row-data span { | ||
margin-right: 3px; | ||
margin-left: 3px; | ||
} | ||
.root-tree .subtree { | ||
display: none; | ||
} | ||
.root-tree .subtree-active { | ||
display: block; | ||
} | ||
.row { | ||
width: calc(100% - var(--min-dimension)); | ||
cursor: pointer; | ||
position: relative; | ||
padding-top: 1px; | ||
padding-bottom: 1px; | ||
padding-right: 1px; | ||
padding-left: var(--min-dimension); | ||
} | ||
.align-items-center { | ||
align-items: center !important; | ||
} | ||
.d-flex { | ||
display: flex !important; | ||
} | ||
.icon-indicator { | ||
left: calc(var(--min-dimension) / 2); | ||
position: absolute; | ||
top: 50%; | ||
transform: translateY(-50%) translateX(-50%); | ||
} | ||
.row-data { | ||
width: 100%; | ||
} | ||
i.icon { | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-font-smoothing: antialiased; | ||
display: inline-block; | ||
font-style: normal; | ||
font-variant: normal; | ||
text-rendering: auto; | ||
line-height: 1; | ||
margin: 0px 2px; | ||
font-family: var(--icon-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-font-weight, 900); | ||
} | ||
i.icon:before { | ||
content: var(--icon-content, '\\f07b'); | ||
} | ||
.item-subtree > div > .icon-indicator { | ||
font-family: var(--icon-fold-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-fold-font-weight, 900); | ||
} | ||
.item-subtree > div > .icon-indicator:before { | ||
content: var(--icon-fold-content, '\\f0da'); | ||
} | ||
.item-active > div > .icon-indicator { | ||
font-family: var(--icon-unfold-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-unfold-font-weight, 900); | ||
} | ||
.item-active > div > .icon-indicator:before { | ||
content: var(--icon-unfold-content, '\\f0d7'); | ||
} | ||
i.icon-0 { | ||
font-family: var(--icon-0-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-0-font-weight, 900); | ||
} | ||
i.icon-0:before { | ||
content: var(--icon-0-content, '\\f07b'); | ||
} | ||
i.icon-1 { | ||
font-family: var(--icon-1-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-1-font-weight, 900); | ||
} | ||
i.icon-1:before { | ||
content: var(--icon-1-content, '\\f07b'); | ||
} | ||
i.icon-2 { | ||
font-family: var(--icon-2-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-2-font-weight, 900); | ||
} | ||
i.icon-2:before { | ||
content: var(--icon-2-content, '\\f07b'); | ||
} | ||
i.icon-3 { | ||
font-family: var(--icon-3-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-3-font-weight, 900); | ||
} | ||
i.icon-3:before { | ||
content: var(--icon-3-content, '\\f07b'); | ||
} | ||
i.icon-4 { | ||
font-family: var(--icon-4-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-4-font-weight, 900); | ||
} | ||
i.icon-4:before { | ||
content: var(--icon-4-content, '\\f07b'); | ||
} | ||
i.icon-5 { | ||
font-family: var(--icon-5-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-5-font-weight, 900); | ||
} | ||
i.icon-5:before { | ||
content: var(--icon-5-content, '\\f07b'); | ||
} | ||
i.icon-6 { | ||
font-family: var(--icon-6-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-6-font-weight, 900); | ||
} | ||
i.icon-6:before { | ||
content: var(--icon-6-content, '\\f07b'); | ||
} | ||
i.icon-7 { | ||
font-family: var(--icon-7-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-7-font-weight, 900); | ||
} | ||
i.icon-7:before { | ||
content: var(--icon-7-content, '\\f07b'); | ||
} | ||
i.icon-8 { | ||
font-family: var(--icon-8-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-8-font-weight, 900); | ||
} | ||
i.icon-8:before { | ||
content: var(--icon-8-content, '\\f07b'); | ||
} | ||
i.icon-9 { | ||
font-family: var(--icon-9-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-9-font-weight, 900); | ||
} | ||
i.icon-9:before { | ||
content: var(--icon-9-content, '\\f07b'); | ||
} | ||
i.icon-10 { | ||
font-family: var(--icon-10-font-family, 'Font Awesome 5 Free'); | ||
font-weight: var(--icon-10-font-weight, 900); | ||
} | ||
i.icon-10:before { | ||
content: var(--icon-10-content, '\\f07b'); | ||
} | ||
`; | ||
/** | ||
* Js-Tree component. | ||
*/ | ||
var J,Z;null==W||W(R,B),(null!==(f=globalThis.litHtmlVersions)&&void 0!==f?f:globalThis.litHtmlVersions=[]).push("2.2.0");class X extends u{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,e,i)=>{var n,s;const o=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:e;let r=o._$litPart$;if(void 0===r){const t=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:null;o._$litPart$=r=new B(e.insertBefore(b(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return H}}X.finalized=!0,X._$litElement$=!0,null===(J=globalThis.litElementHydrateSupport)||void 0===J||J.call(globalThis,{LitElement:X});const Y=globalThis.litElementPolyfillSupport;null==Y||Y({LitElement:X}),(null!==(Z=globalThis.litElementVersions)&&void 0!==Z?Z:globalThis.litElementVersions=[]).push("3.2.0");const G=((t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new s(n,i)})`.root-tree{padding-left:0;margin-left:1px;margin-right:1px;--min-dimension:var(--min-clickable-dimension, 24px)}.root-tree li{list-style-type:none}.root-tree .row-data:focus,.root-tree .row-data:hover{color:var(--hover-text-color,#000)}.root-tree .row-data.jstree-clicked,.root-tree .row-data.jstree-clicked span{background-color:var(--selected-background-color,transparent);color:var(--selected-text-color,#000)}.root-tree .row,.root-tree .row-data{display:inline-block;min-height:var(--min-dimension);min-width:var(--min-dimension)}.root-tree .row-data span{margin-right:3px;margin-left:3px}.root-tree .subtree{display:none}.root-tree .subtree-active{display:block}.row{width:calc(100% - var(--min-dimension));cursor:pointer;position:relative;padding-top:1px;padding-bottom:1px;padding-right:1px;padding-left:var(--min-dimension)}.align-items-center{align-items:center!important}.d-flex{display:flex!important}.icon-indicator{left:calc(var(--min-dimension)/ 2);position:absolute;top:50%;transform:translateY(-50%) translateX(-50%)}.row-data{width:100%}i.icon{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1;margin:0 2px;font-family:var(--icon-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-font-weight,900)}i.icon:before{content:var(--icon-content, '\\f07b')}.item-subtree>div>.icon-indicator{font-family:var(--icon-fold-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-fold-font-weight,900)}.item-subtree>div>.icon-indicator:before{content:var(--icon-fold-content, '\\f0da')}.item-active>div>.icon-indicator{font-family:var(--icon-unfold-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-unfold-font-weight,900)}.item-active>div>.icon-indicator:before{content:var(--icon-unfold-content, '\\f0d7')}i.icon-0{font-family:var(--icon-0-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-0-font-weight,900)}i.icon-0:before{content:var(--icon-0-content, '\\f07b')}i.icon-1{font-family:var(--icon-1-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-1-font-weight,900)}i.icon-1:before{content:var(--icon-1-content, '\\f07b')}i.icon-2{font-family:var(--icon-2-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-2-font-weight,900)}i.icon-2:before{content:var(--icon-2-content, '\\f07b')}i.icon-3{font-family:var(--icon-3-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-3-font-weight,900)}i.icon-3:before{content:var(--icon-3-content, '\\f07b')}i.icon-4{font-family:var(--icon-4-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-4-font-weight,900)}i.icon-4:before{content:var(--icon-4-content, '\\f07b')}i.icon-5{font-family:var(--icon-5-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-5-font-weight,900)}i.icon-5:before{content:var(--icon-5-content, '\\f07b')}i.icon-6{font-family:var(--icon-6-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-6-font-weight,900)}i.icon-6:before{content:var(--icon-6-content, '\\f07b')}i.icon-7{font-family:var(--icon-7-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-7-font-weight,900)}i.icon-7:before{content:var(--icon-7-content, '\\f07b')}i.icon-8{font-family:var(--icon-8-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-8-font-weight,900)}i.icon-8:before{content:var(--icon-8-content, '\\f07b')}i.icon-9{font-family:var(--icon-9-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-9-font-weight,900)}i.icon-9:before{content:var(--icon-9-content, '\\f07b')}i.icon-10{font-family:var(--icon-10-font-family, 'Font Awesome 5 Free');font-weight:var(--icon-10-font-weight,900)}i.icon-10:before{content:var(--icon-10-content, '\\f07b')}`;class Q extends X{static get styles(){return[G]}static get properties(){return{datas:{attribute:!1},config:{attribute:!1},onSelection:{attribute:!1}}}constructor(){super(),this._datas=[],this._initKeyboardNavigation=!1,this._activeElement=null}render(){return this._renderTree(this._datas,0,null)}willUpdate(t){super.willUpdate(t);let e=!1;t&&(e=t.has("datas")||t.has("config")),e&&(this._datas=this.datas,this._initKeyboardNavigation=!1,this._initDataList(this._datas,this.config.identifier),this._activeElement=this._datas&&this._datas.length>0?this._datas[0]:null)}updated(t){super.updated(t),this.shadowRoot.querySelectorAll('input[type="checkbox"]').forEach((t=>{const e=this._findDatasByProperty(this._datas,"idHtml",t.id.replace("-checkbox",""));e&&1===e.length&&(t.checked=e[0].selected)})),this._initKeyboardNavigation&&this.activeElement&&this.shadowRoot.querySelectorAll("li").forEach((t=>{t.id===this.activeElement.idHtml&&t.focus()}))}selectNode(t){if(t){const e=this._findDatasByProperty(this._datas,"id",t);e&&e.length>0&&!e[0].selected&&this._onClickItem(null,e[0])}}deselectAllNodes(){const t=this._findDatasByProperty(this._datas,"selected",!0);t&&t.length>0&&(this._unSelectDatas(this._datas),this.requestUpdate(),this._sendSelection())}addNode(t,e){if(t){const i=this._findDatasByProperty(this._datas,"id",t);i&&i.length>0&&i[0].areChildrenLoaded&&(this._initDataList([e],i[0].idHtml),e.parent=i[0],i[0].loadedChildren.push(e),this.requestUpdate())}else this._initDataList([e],this.config.identifier),e.parent=null,this._datas.push(e),this.requestUpdate()}deleteNode(t){if(t){const e=this._findDatasByProperty(this._datas,"id",t);if(e&&e.length>0){const t=this._findDatasByProperty(this._datas,"selected",!0);e[0].parent?e[0].parent.loadedChildren=e[0].parent.loadedChildren.filter((t=>t.id!==e[0].id)):this._datas=this._datas.filter((t=>t.id!==e[0].id)),this.requestUpdate();const i=this._findDatasByProperty(this._datas,"selected",!0);t.length!==i.length&&this._sendSelection()}}}refreshNode(t,e,i=!1){if(t){const n=this._findDatasByProperty(this._datas,"id",t);if(n&&n.length>0){const t=this._findDatasByProperty(this._datas,"selected",!0);this._refreshNodes(n[0],e,i).then((()=>{this.requestUpdate();const e=this._findDatasByProperty(this._datas,"selected",!0);t.length!==e.length&&this._sendSelection()}))}}}_renderTree(t,e,i){return this.config.sort&&t.sort(((t,e)=>t.text.localeCompare(e.text))),D`<ul id="${this.config.identifier}" class="${0===e?"root-tree":i.ulClasses.join(" ")}" role="${0===e?this.config.isMultipleSelection?"listbox":"tree":"group"}" aria-multiselectable="${0===e&&this.config.isMultipleSelection?"true":"false"}" tabindex="${0===e?"0":"-1"}" aria-activedescendant="${0===e&&this.activeElement?this.activeElement.idHtml:""}" aria-labelledby="${i?i.idHtml+"-text":""}" @keydown="${t=>this._onKeyDown(t)}">${(t||[]).map((t=>D`<li id="${t.idHtml}" class="${t.liClasses.join(" ")}" tabindex="-1" aria-expanded="${t.expanded}" role="${this.config.showCheckbox?"option":"treeitem"}" aria-selected="${t.selected}"><div class="row" @click="${e=>this._onClickRow(e,t)}">${this._renderIconIndicator(t)}<div class="row-data d-flex align-items-center ${t.selected?"jstree-clicked":""}" @click="${e=>this._onClickItem(e,t)}">${this._renderCheckbox(t)} <i class="icon ${null!==t.iconIndex?"icon-"+t.iconIndex:""}" aria-hidden="true"></i> <span id="${t.idHtml}-text">${t.text}</span></div></div>${t.loadedChildren?this._renderTree(t.loadedChildren,e+1,t):""}</li>`))}</ul>`}_renderIconIndicator(t){return t.children&&(!t.areChildrenLoaded||t.loadedChildren&&t.loadedChildren.length>0)?D`<i class="icon icon-indicator"></i>`:D``}_renderCheckbox(t){return this.config.showCheckbox?D`<input type="checkbox" id="${t.idHtml}-checkbox" tabindex="-1" ?checked="${t.selected}" aria-checked="${t.selected}" aria-labelledby="${t.idHtml}-text" ?disabled="${!1===this.config.allowDeselection&&t.selected}">`:D``}_onClickItem(t,e){if(t&&t.stopPropagation(),this.activeElement=e,!1!==this.config.allowDeselection||!e.selected){const t=e.selected;this.config.isMultipleSelection||this._unSelectDatas(this._datas),e.selected=!t,this.requestUpdate(),this._sendSelection()}}_onClickRow(t,e){t.stopPropagation(),this.activeElement=e,e.children&&(e.expanded?(e.expanded=!1,e.ulClasses.includes("subtree-active")&&e.ulClasses.splice(e.ulClasses.indexOf("subtree-active"),1),e.liClasses.includes("item-active")&&e.liClasses.splice(e.liClasses.indexOf("item-active"),1),this.requestUpdate()):e.children&&(e.expanded=!0,e.ulClasses.push("subtree-active"),e.liClasses.push("item-active"),e.areChildrenLoaded?this.requestUpdate():this._loadDataChildren(e,(()=>this.requestUpdate()))))}_onKeyDown(t){if(13===t.keyCode||32===t.keyCode)this._onClickItem(t,this.activeElement);else if(37===t.keyCode)this.activeElement.expanded?(this.activeElement.expanded=!1,this.activeElement.ulClasses.includes("subtree-active")&&this.activeElement.ulClasses.splice(this.activeElement.ulClasses.indexOf("subtree-active"),1),this.activeElement.liClasses.includes("item-active")&&this.activeElement.liClasses.splice(this.activeElement.liClasses.indexOf("item-active"),1)):this.activeElement.parent&&this.activeElement.parent.expanded&&(this.activeElement=this.activeElement.parent),t.preventDefault(),t.stopPropagation(),this.requestUpdate();else if(38===t.keyCode){const e=this._getUpVisibleSiblingElement(this.activeElement);null!=e&&(this.activeElement=e),t.preventDefault(),t.stopPropagation(),this.requestUpdate()}else if(39===t.keyCode)this.activeElement.children?this.activeElement.expanded?(this.activeElement.loadedChildren&&this.activeElement.loadedChildren.length>0&&(this.activeElement=this.activeElement.loadedChildren[0]),t.preventDefault(),t.stopPropagation(),this.requestUpdate()):(this.activeElement.expanded=!0,this.activeElement.ulClasses.push("subtree-active"),this.activeElement.liClasses.push("item-active"),this._loadDataChildren(this.activeElement,(()=>{t.preventDefault(),t.stopPropagation(),this.requestUpdate()}))):(t.preventDefault(),t.stopPropagation());else if(40===t.keyCode){if(this._initKeyboardNavigation)if(this.activeElement.expanded&&this.activeElement.loadedChildren&&this.activeElement.loadedChildren.length>0)this.activeElement=this.activeElement.loadedChildren[0];else{const t=this._getDownVisibleSiblingElement(this.activeElement);null!=t&&(this.activeElement=t)}t.preventDefault(),t.stopPropagation(),this.requestUpdate()}this._initKeyboardNavigation=!0}_initDataList(t,e){t&&t.length>0&&t.forEach((t=>{t.ulClasses=["subtree"],t.liClasses=[],t.children&&t.liClasses.push("item-subtree"),t.expanded=!1,t.parent=null,t.idHtml=(e||"")+"-"+t.id,t.selected=!1,t.loadedChildren=null,t.areChildrenLoaded=!1}))}_unSelectDatas(t){t.forEach((t=>{t.selected=!1,t.loadedChildren&&this._unSelectDatas(t.loadedChildren)}))}_findDatasByProperty(t,e,i){let n=[];return t.forEach((t=>{t[e]===i&&n.push(t),t.children&&t.loadedChildren&&(n=n.concat(this._findDatasByProperty(t.loadedChildren,e,i)))})),n}_loadDataChildren(t,e){this._getChildren(t,(i=>{this._initDataList(i,t.idHtml),t.loadedChildren=i,t.loadedChildren.forEach((e=>e.parent=t)),t.areChildrenLoaded=!0,e&&e()}))}_getChildren(t,e){"function"==typeof t.getChildren?t.getChildren().then((t=>{e(t)})):(Array.isArray(t.getChildren)||t.getChildren instanceof Array)&&e(t.getChildren)}_getDownVisibleSiblingElement(t){if(t.parent){for(let e=0;e<t.parent.loadedChildren.length;e++)if(t.parent.loadedChildren[e].id===t.id)return e<t.parent.loadedChildren.length-1?t.parent.loadedChildren[e+1]:this._getDownVisibleSiblingElement(t.parent)}else for(let e=0;e<this._datas.length;e++)if(this._datas[e].id===t.id&&e<this._datas.length-1)return this._datas[e+1];return null}_getUpVisibleSiblingElement(t){if(t.parent){for(let e=0;e<t.parent.loadedChildren.length;e++)if(t.parent.loadedChildren[e].id===t.id)return e>0?this._getLastVisibleChild(t.parent.loadedChildren[e-1]):t.parent}else for(let e=0;e<this._datas.length;e++)if(this._datas[e].id===t.id&&e>0)return this._getLastVisibleChild(this._datas[e-1]);return null}_getLastVisibleChild(t){return t.expanded&&t.loadedChildren&&t.loadedChildren.length>0?this._getLastVisibleChild(t.loadedChildren[t.loadedChildren.length-1]):t}_sendSelection(){if(this.onSelection){const t=this._findDatasByProperty(this._datas,"selected",!0);this.onSelection(t)}}_refreshNodes(t,e,i){return new Promise((n=>{Object.assign(t,e),i&&t.children&&t.areChildrenLoaded?this._getChildren(t,(e=>{const s=e.map((t=>t.id));t.loadedChildren=t.loadedChildren.filter((t=>s.includes(t.id)));let o=0;const r=[];e.forEach((e=>{const n=t.loadedChildren.find((t=>t.id===e.id));n?r.push(this._refreshNodes(n,e,i)):(this._initDataList([e],t.idHtml),e.parent=t,t.loadedChildren.splice(o,0,e)),o++})),Promise.all(r).then((()=>n()))})):n()}))}}customElements.get("esup-js-tree")||customElements.define("esup-js-tree",Q),t.JsTree=Q,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
class JsTree extends s { | ||
static get styles() { | ||
return [jsTreeStyle] | ||
} | ||
static get properties() { | ||
return { | ||
/** | ||
* Tableau des valeurs racine de l'arbre. | ||
* @type {Array} | ||
*/ | ||
datas: { attribute: false }, | ||
/** | ||
* Configuration de l'arbre. | ||
* @type {Object} | ||
*/ | ||
config: { attribute: false }, | ||
/** | ||
* Fonction appelée à la sélection d'un élement de l'arbre. | ||
* @type {Function} | ||
*/ | ||
onSelection: { attribute: false } | ||
} | ||
} | ||
constructor() { | ||
super(); | ||
this._datas = []; | ||
this._initKeyboardNavigation = false; | ||
this._activeElement = null; | ||
} | ||
render() { | ||
return this._renderTree(this._datas, 0, null) | ||
} | ||
willUpdate(changedProperties) { | ||
super.willUpdate(changedProperties); | ||
// Si les propriétés datas ou config sont modifiées, on initialise les éléments | ||
let initDatas = false; | ||
if (changedProperties) { | ||
initDatas = changedProperties.has('datas') || changedProperties.has('config'); | ||
} | ||
if (initDatas) { | ||
// Initialisation des données | ||
this._datas = this.datas; | ||
this._initKeyboardNavigation = false; | ||
this._initDataList(this._datas, this.config.identifier); | ||
// Initialisation de la navigation au clavier | ||
this._activeElement = | ||
this._datas && this._datas.length > 0 ? this._datas[0] : null; | ||
} | ||
} | ||
updated(changedProperties) { | ||
super.updated(changedProperties); | ||
// Cochage des checkbox des éléments sélectionnés | ||
this.shadowRoot.querySelectorAll('input[type="checkbox"]').forEach(el => { | ||
const data = this._findDatasByProperty( | ||
this._datas, | ||
'idHtml', | ||
el.id.replace('-checkbox', '') | ||
); | ||
if (data && data.length === 1) { | ||
el.checked = data[0].selected; | ||
} | ||
}); | ||
// Focus sur l'élément actif | ||
if (this._initKeyboardNavigation && this.activeElement) { | ||
this.shadowRoot.querySelectorAll('li').forEach(el => { | ||
if (el.id === this.activeElement.idHtml) { | ||
el.focus(); | ||
} | ||
}); | ||
} | ||
} | ||
/** | ||
* Méthode permettant de sélectionner un noeud à partir de son id. | ||
* | ||
* @param {String} id Identifiant du noeud | ||
*/ | ||
selectNode(id) { | ||
if (id) { | ||
const data = this._findDatasByProperty(this._datas, 'id', id); | ||
if (data && data.length > 0 && !data[0].selected) { | ||
this._onClickItem(null, data[0]); | ||
} | ||
} | ||
} | ||
/** | ||
* Méthode permettant de désélectionner tous les noeuds. | ||
*/ | ||
deselectAllNodes() { | ||
const previousSelectedDatas = this._findDatasByProperty( | ||
this._datas, | ||
'selected', | ||
true | ||
); | ||
if (previousSelectedDatas && previousSelectedDatas.length > 0) { | ||
this._unSelectDatas(this._datas); | ||
this.requestUpdate(); | ||
// Information d'une sélection/désélection | ||
this._sendSelection(); | ||
} | ||
} | ||
/** | ||
* Méthode permettant d'ajouter un nouveau noeud. | ||
* | ||
* @param {String} idParent Identifiant du noeud parent | ||
* @param {Object} properties Propriétés du nouveau noeud | ||
*/ | ||
addNode(idParent, properties) { | ||
if (idParent) { | ||
const parent = this._findDatasByProperty(this._datas, 'id', idParent); | ||
if (parent && parent.length > 0 && parent[0].areChildrenLoaded) { | ||
this._initDataList([properties], parent[0].idHtml); | ||
properties.parent = parent[0]; | ||
parent[0].loadedChildren.push(properties); | ||
this.requestUpdate(); | ||
} | ||
} else { | ||
this._initDataList([properties], this.config.identifier); | ||
properties.parent = null; | ||
this._datas.push(properties); | ||
this.requestUpdate(); | ||
} | ||
} | ||
/** | ||
* Méthode permettant de supprimer un noeud à partir de son id. | ||
* | ||
* @param {String} id Identifiant du noeud | ||
*/ | ||
deleteNode(id) { | ||
if (id) { | ||
const data = this._findDatasByProperty(this._datas, 'id', id); | ||
if (data && data.length > 0) { | ||
const previousSelectedDatas = this._findDatasByProperty( | ||
this._datas, | ||
'selected', | ||
true | ||
); | ||
if (data[0].parent) { | ||
data[0].parent.loadedChildren = data[0].parent.loadedChildren.filter( | ||
child => child.id !== data[0].id | ||
); | ||
} else { | ||
this._datas = this._datas.filter(child => child.id !== data[0].id); | ||
} | ||
this.requestUpdate(); | ||
const nextSelectedDatas = this._findDatasByProperty( | ||
this._datas, | ||
'selected', | ||
true | ||
); | ||
if (previousSelectedDatas.length !== nextSelectedDatas.length) { | ||
// Information d'une désélection | ||
this._sendSelection(); | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Méthode permettant de recharger un noeud. | ||
* | ||
* @param {String} id Identifiant du noeud | ||
* @param {Object} properties Nouvelles propriétés du noeud | ||
* @param {Boolean} refreshChildren Indique s'il faut rafraichir les enfants | ||
*/ | ||
refreshNode(id, properties, refreshChildren = false) { | ||
if (id) { | ||
const data = this._findDatasByProperty(this._datas, 'id', id); | ||
if (data && data.length > 0) { | ||
const previousSelectedDatas = this._findDatasByProperty( | ||
this._datas, | ||
'selected', | ||
true | ||
); | ||
this._refreshNodes(data[0], properties, refreshChildren).then(() => { | ||
this.requestUpdate(); | ||
const nextSelectedDatas = this._findDatasByProperty( | ||
this._datas, | ||
'selected', | ||
true | ||
); | ||
if (previousSelectedDatas.length !== nextSelectedDatas.length) { | ||
// Information d'une désélection | ||
this._sendSelection(); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Fonction récursive pour construire un niveau de l'arborescence. | ||
* | ||
* @param {Array} datas Tableau des éléments du niveau actuel | ||
* @param {Number} level Profondeur du niveau actuel | ||
* @param {Object} parent Elément parent du niveau actuel | ||
* @returns Code HTML | ||
*/ | ||
_renderTree(datas, level, parent) { | ||
// Tri des noeuds si demandé | ||
if (this.config.sort) { | ||
datas.sort((node1, node2) => | ||
node1.text.localeCompare(node2.text) | ||
); | ||
} | ||
// prettier-ignore | ||
return $` | ||
<ul id="${this.config.identifier}" class="${level === 0 ? 'root-tree' : parent.ulClasses.join(' ')}" | ||
role="${level === 0 ? (this.config.isMultipleSelection ? 'listbox' : 'tree') : 'group'}" | ||
aria-multiselectable="${level === 0 && this.config.isMultipleSelection ? 'true' : 'false'}" tabindex="${level === 0 ? '0' : '-1'}" | ||
aria-activedescendant="${level === 0 && this.activeElement ? this.activeElement.idHtml : ''}" | ||
aria-labelledby="${parent ? parent.idHtml + '-text' : ''}" @keydown="${(e) => this._onKeyDown(e)}"> | ||
${(datas || []).map((data) => { | ||
return $` | ||
<li id ="${data.idHtml}" class="${data.liClasses.join(' ')}" tabindex="-1" aria-expanded="${data.expanded}" | ||
role="${this.config.showCheckbox ? 'option' : 'treeitem'}" aria-selected="${data.selected}"> | ||
<div class="row" @click="${(e) => this._onClickRow(e, data)}"> | ||
${this._renderIconIndicator(data)} | ||
<div class="row-data d-flex align-items-center ${data.selected ? 'jstree-clicked' : ''}" @click="${(e) => this._onClickItem(e, data)}"> | ||
${this._renderCheckbox(data)} | ||
<i class="icon ${data.iconIndex !== null ? 'icon-' + data.iconIndex : ''}" aria-hidden="true"></i> | ||
<span id="${data.idHtml}-text">${data.text}</span> | ||
</div> | ||
</div> | ||
${data.loadedChildren ? this._renderTree(data.loadedChildren, level + 1 , data) : ''} | ||
</li>` | ||
})} | ||
</ul> | ||
` | ||
} | ||
/** | ||
* Retourne le code HTML de l'icône plié/déplié d'un élement. | ||
* | ||
* @param {Object} data Elément | ||
* @returns Code HTML | ||
*/ | ||
_renderIconIndicator(data) { | ||
if (data.children && (!data.areChildrenLoaded || (data.loadedChildren && data.loadedChildren.length > 0))) { | ||
// prettier-ignore | ||
return $`<i class="icon icon-indicator"></i>` | ||
} else { | ||
return $`` | ||
} | ||
} | ||
/** | ||
* Retourne le code HTML de la checkbox d'un élement. | ||
* | ||
* @param {Object} data Elément | ||
* @returns Code HTML | ||
*/ | ||
_renderCheckbox(data) { | ||
if (this.config.showCheckbox) { | ||
// prettier-ignore | ||
return $`<input type="checkbox" id ="${data.idHtml}-checkbox" | ||
tabindex="-1" ?checked="${data.selected}" aria-checked="${data.selected}" aria-labelledby="${data.idHtml}-text" | ||
?disabled="${this.config.allowDeselection === false && data.selected}">` | ||
} else { | ||
return $`` | ||
} | ||
} | ||
/** | ||
* Méthode appelé au clic sur un élément entrainant sa sélection/désélection. | ||
* | ||
* @param {Object} event Evènement | ||
* @param {Object} data Elément cliqué | ||
*/ | ||
_onClickItem(event, data) { | ||
if (event) { | ||
event.stopPropagation(); | ||
} | ||
this.activeElement = data; | ||
if (this.config.allowDeselection !== false || !data.selected) { | ||
const oldValue = data.selected; | ||
// Si sélection simple, on désélectionne les éléments préalablement sélectionnés | ||
if (!this.config.isMultipleSelection) { | ||
this._unSelectDatas(this._datas); | ||
} | ||
data.selected = !oldValue; | ||
this.requestUpdate(); | ||
// Information d'une sélection/désélection | ||
this._sendSelection(); | ||
} | ||
} | ||
/** | ||
* Méthode appelé au clic sur une ligne de l'arborescence entrainant son dépliage/repliage. | ||
* | ||
* @param {Object} event Evènement | ||
* @param {Object} data Elément cliqué | ||
*/ | ||
_onClickRow(event, data) { | ||
event.stopPropagation(); | ||
this.activeElement = data; | ||
if (data.children) { | ||
if (data.expanded) { | ||
// On replie l'élément | ||
data.expanded = false; | ||
if (data.ulClasses.includes('subtree-active')) { | ||
data.ulClasses.splice(data.ulClasses.indexOf('subtree-active'), 1); | ||
} | ||
if (data.liClasses.includes('item-active')) { | ||
data.liClasses.splice(data.liClasses.indexOf('item-active'), 1); | ||
} | ||
this.requestUpdate(); | ||
} else { | ||
// On déplie l'élément | ||
if (data.children) { | ||
data.expanded = true; | ||
data.ulClasses.push('subtree-active'); | ||
data.liClasses.push('item-active'); | ||
if (!data.areChildrenLoaded) { | ||
this._loadDataChildren(data, () => this.requestUpdate()); | ||
} else { | ||
this.requestUpdate(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Méthode appelé à la navigation au clavier dans l'arborescence. | ||
* | ||
* @param {Object} event Evènement | ||
*/ | ||
_onKeyDown(event) { | ||
if (event.keyCode === 13 || event.keyCode === 32) { | ||
// Touche entrée ou Espace | ||
this._onClickItem(event, this.activeElement); | ||
} else if (event.keyCode === 37) { | ||
// Touche gauche | ||
// On replie l'élément actif | ||
if (this.activeElement.expanded) { | ||
this.activeElement.expanded = false; | ||
if (this.activeElement.ulClasses.includes('subtree-active')) { | ||
this.activeElement.ulClasses.splice( | ||
this.activeElement.ulClasses.indexOf('subtree-active'), | ||
1 | ||
); | ||
} | ||
if (this.activeElement.liClasses.includes('item-active')) { | ||
this.activeElement.liClasses.splice( | ||
this.activeElement.liClasses.indexOf('item-active'), | ||
1 | ||
); | ||
} | ||
} else if ( | ||
this.activeElement.parent && | ||
this.activeElement.parent.expanded | ||
) { | ||
this.activeElement = this.activeElement.parent; | ||
} | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
this.requestUpdate(); | ||
} else if (event.keyCode === 38) { | ||
// Touche haut | ||
// On se déplace sur l'élement au dessus | ||
const sibbling = this._getUpVisibleSiblingElement(this.activeElement); | ||
if (sibbling != null) { | ||
this.activeElement = sibbling; | ||
} | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
this.requestUpdate(); | ||
} else if (event.keyCode === 39) { | ||
// Touche droite | ||
// On déplie l'élément actif | ||
if (this.activeElement.children) { | ||
if (this.activeElement.expanded) { | ||
if ( | ||
this.activeElement.loadedChildren && | ||
this.activeElement.loadedChildren.length > 0 | ||
) { | ||
this.activeElement = this.activeElement.loadedChildren[0]; | ||
} | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
this.requestUpdate(); | ||
} else { | ||
this.activeElement.expanded = true; | ||
this.activeElement.ulClasses.push('subtree-active'); | ||
this.activeElement.liClasses.push('item-active'); | ||
this._loadDataChildren(this.activeElement, () => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
this.requestUpdate(); | ||
}); | ||
} | ||
} else { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
} else if (event.keyCode === 40) { | ||
// Touche bas | ||
// On se déplace sur l'élement en dessus | ||
if (this._initKeyboardNavigation) { | ||
if ( | ||
this.activeElement.expanded && | ||
this.activeElement.loadedChildren && | ||
this.activeElement.loadedChildren.length > 0 | ||
) { | ||
this.activeElement = this.activeElement.loadedChildren[0]; | ||
} else { | ||
const sibbling = this._getDownVisibleSiblingElement( | ||
this.activeElement | ||
); | ||
if (sibbling != null) { | ||
this.activeElement = sibbling; | ||
} | ||
} | ||
} | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
this.requestUpdate(); | ||
} | ||
this._initKeyboardNavigation = true; | ||
} | ||
/** | ||
* Initialisation des données des éléments. | ||
* | ||
* @param {Array} datas Tableau des éléments | ||
* @param {String} parentIdHtml Identifiant HTML du parent des éléments | ||
*/ | ||
_initDataList(datas, parentIdHtml) { | ||
if (datas && datas.length > 0) { | ||
datas.forEach(data => { | ||
data.ulClasses = ['subtree']; | ||
data.liClasses = []; | ||
if (data.children) { | ||
data.liClasses.push('item-subtree'); | ||
} | ||
data.expanded = false; | ||
data.parent = null; | ||
data.idHtml = (parentIdHtml || '') + '-' + data.id; | ||
data.selected = false; | ||
data.loadedChildren = null; | ||
data.areChildrenLoaded = false; | ||
}); | ||
} | ||
} | ||
/** | ||
* Méthode récursive permettant de désélectionner tous les éléments. | ||
* | ||
* @param {Array} datas Tableau des éléments | ||
*/ | ||
_unSelectDatas(datas) { | ||
datas.forEach(data => { | ||
data.selected = false; | ||
if (data.loadedChildren) { | ||
this._unSelectDatas(data.loadedChildren); | ||
} | ||
}); | ||
} | ||
/** | ||
* Méthode récursive permettant de recherche des éléments selon une propriété. | ||
* | ||
* @param {Array} datas Tableau des éléments | ||
* @param {String} propertyName Nom de la propriété recherchée | ||
* @param {String|Number} propertyValue Valeur de la propriété recherchée | ||
* @returns Tableau des éléments trouvés | ||
*/ | ||
_findDatasByProperty(datas, propertyName, propertyValue) { | ||
let result = []; | ||
datas.forEach(data => { | ||
if (data[propertyName] === propertyValue) { | ||
result.push(data); | ||
} | ||
if (data.children && data.loadedChildren) { | ||
result = result.concat( | ||
this._findDatasByProperty( | ||
data.loadedChildren, | ||
propertyName, | ||
propertyValue | ||
) | ||
); | ||
} | ||
}); | ||
return result | ||
} | ||
/** | ||
* Méthode chargeant les enfants d'un élément. | ||
* | ||
* @param {Object} data Elément | ||
* @param {Function} callback Fonction appelé après le chargement des enfants | ||
*/ | ||
_loadDataChildren(data, callback) { | ||
this._getChildren(data, children => { | ||
this._initDataList(children, data.idHtml); | ||
data.loadedChildren = children; | ||
data.loadedChildren.forEach(child => (child.parent = data)); | ||
data.areChildrenLoaded = true; | ||
if (callback) { | ||
callback(); | ||
} | ||
}); | ||
} | ||
/** | ||
* Méthode récupérant les enfants d'un élément. | ||
* | ||
* @param {Object} data Elément | ||
* @param {Function} callback Fonction appelé après la récupération des enfants | ||
*/ | ||
_getChildren(data, callback) { | ||
if (typeof data.getChildren === 'function') { | ||
data.getChildren().then(children => { | ||
callback(children); | ||
}); | ||
} else if ( | ||
Array.isArray(data.getChildren) || | ||
data.getChildren instanceof Array | ||
) { | ||
callback(data.getChildren); | ||
} | ||
} | ||
/** | ||
* Méthode récursive permettant de trouver l'élément en dessous d'un élément donné. | ||
* | ||
* @param {Object} element Elément | ||
* @returns Elément en dessous | ||
*/ | ||
_getDownVisibleSiblingElement(element) { | ||
if (element.parent) { | ||
for (let i = 0; i < element.parent.loadedChildren.length; i++) { | ||
if (element.parent.loadedChildren[i].id === element.id) { | ||
if (i < element.parent.loadedChildren.length - 1) { | ||
return element.parent.loadedChildren[i + 1] | ||
} else { | ||
return this._getDownVisibleSiblingElement(element.parent) | ||
} | ||
} | ||
} | ||
} else { | ||
for (let i = 0; i < this._datas.length; i++) { | ||
if (this._datas[i].id === element.id) { | ||
if (i < this._datas.length - 1) { | ||
return this._datas[i + 1] | ||
} | ||
} | ||
} | ||
} | ||
return null | ||
} | ||
/** | ||
* Méthode permettant de trouver l'élément au dessus d'un élément donné. | ||
* | ||
* @param {Object} element Elément | ||
* @returns Elément au dessus | ||
*/ | ||
_getUpVisibleSiblingElement(element) { | ||
if (element.parent) { | ||
for (let i = 0; i < element.parent.loadedChildren.length; i++) { | ||
if (element.parent.loadedChildren[i].id === element.id) { | ||
if (i > 0) { | ||
return this._getLastVisibleChild( | ||
element.parent.loadedChildren[i - 1] | ||
) | ||
} else { | ||
return element.parent | ||
} | ||
} | ||
} | ||
} else { | ||
for (let i = 0; i < this._datas.length; i++) { | ||
if (this._datas[i].id === element.id) { | ||
if (i > 0) { | ||
return this._getLastVisibleChild(this._datas[i - 1]) | ||
} | ||
} | ||
} | ||
} | ||
return null | ||
} | ||
/** | ||
* Méthode récursive permettant de trouver l'élément enfant le plus bas d'un élément donné. | ||
* | ||
* @param {Object} element Elément | ||
* @returns Elément le plus bas | ||
*/ | ||
_getLastVisibleChild(element) { | ||
if ( | ||
element.expanded && | ||
element.loadedChildren && | ||
element.loadedChildren.length > 0 | ||
) { | ||
return this._getLastVisibleChild( | ||
element.loadedChildren[element.loadedChildren.length - 1] | ||
) | ||
} else { | ||
return element | ||
} | ||
} | ||
/** | ||
* Méthode pour indiquer qu'une sélection/désélection a été faite. | ||
*/ | ||
_sendSelection() { | ||
// Appel de la méthode pour informer d'une sélection/désélection | ||
if (this.onSelection) { | ||
const selectedDatas = this._findDatasByProperty( | ||
this._datas, | ||
'selected', | ||
true | ||
); | ||
this.onSelection(selectedDatas); | ||
} | ||
} | ||
/** | ||
* Méthode permettant de recharger des noeuds. | ||
* | ||
* @param {Object} oldNode Anciennes données du noeud | ||
* @param {Object} newNode Nouvelles données du noeud | ||
* @param {Boolean} refreshChildren Indique s'il faut rafraichir les enfants du noeud | ||
*/ | ||
_refreshNodes(oldNode, newNode, refreshChildren) { | ||
return new Promise(resolve => { | ||
Object.assign(oldNode, newNode); | ||
if (refreshChildren && oldNode.children && oldNode.areChildrenLoaded) { | ||
this._getChildren(oldNode, newChildren => { | ||
// Suppresson des enfants qui ne sont plus là | ||
const newIds = newChildren.map(c => c.id); | ||
oldNode.loadedChildren = oldNode.loadedChildren.filter(child => | ||
newIds.includes(child.id) | ||
); | ||
// Ajout/Mise à jour des enfants | ||
let index = 0; | ||
const promises = []; | ||
newChildren.forEach(newChild => { | ||
const oldChild = oldNode.loadedChildren.find( | ||
c => c.id === newChild.id | ||
); | ||
if (!oldChild) { | ||
this._initDataList([newChild], oldNode.idHtml); | ||
newChild.parent = oldNode; | ||
oldNode.loadedChildren.splice(index, 0, newChild); | ||
} else { | ||
promises.push( | ||
this._refreshNodes(oldChild, newChild, refreshChildren) | ||
); | ||
} | ||
index++; | ||
}); | ||
Promise.all(promises).then(() => resolve()); | ||
}); | ||
} else { | ||
resolve(); | ||
} | ||
}) | ||
} | ||
} | ||
if (!customElements.get('esup-js-tree')) { | ||
customElements.define('esup-js-tree', JsTree); | ||
} | ||
exports.JsTree = JsTree; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); |
{ | ||
"name": "@gip-recia/js-tree", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Js Tree", | ||
@@ -59,5 +59,6 @@ "main": "src/js-tree.js", | ||
"rollup-plugin-summary": "^1.3.0", | ||
"rollup-plugin-terser": "^7.0.2" | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-visualizer": "^5.6.0" | ||
}, | ||
"customElements": "custom-elements.json" | ||
} |
@@ -32,9 +32,13 @@ # **Esup Js-Tree** | ||
```html | ||
<script src="./path/to/js-tree.bundle.js"></script> | ||
<script src="./path/to/js-tree.bundle.min.js"></script> | ||
``` | ||
3. Ajout du composant dans l'application/composant : | ||
3. Ajout du composant sur une page HTML : | ||
```html | ||
<esup-js-tree .datas="..." .config="..." .onSelection="..."></esup-js-tree> | ||
```js | ||
const tree = document.createElement('esup-js-tree'); | ||
tree.datas = [...]; | ||
tree.config = {...}; | ||
tree.onSelection = (data) => ...; | ||
document.body.appendChild(tree); | ||
``` | ||
@@ -41,0 +45,0 @@ |
@@ -6,23 +6,54 @@ // Import rollup plugins | ||
import summary from 'rollup-plugin-summary' | ||
import { visualizer } from 'rollup-plugin-visualizer' | ||
export default { | ||
plugins: [ | ||
// Resolve bare module specifiers to relative paths | ||
resolve(), | ||
// Minify HTML template literals | ||
minifyHTML(), | ||
// Minify JS | ||
terser({ | ||
ecma: 2020 | ||
}), | ||
// Print bundle summary | ||
summary() | ||
], | ||
input: 'src/js-tree.js', | ||
output: { | ||
file: 'dist/js-tree.bundle.js', | ||
name: 'esupJsTree', | ||
format: 'umd' | ||
export default [ | ||
// Non-minified bundle | ||
{ | ||
plugins: [ | ||
// Resolve bare module specifiers to relative paths | ||
resolve(), | ||
// Print bundle summary | ||
summary() | ||
], | ||
input: 'src/js-tree.js', | ||
output: [ | ||
{ | ||
file: 'dist/js-tree.bundle.js', | ||
name: 'esupJsTree', | ||
format: 'umd' | ||
} | ||
], | ||
preserveEntrySignatures: 'strict' | ||
}, | ||
preserveEntrySignatures: 'strict' | ||
} | ||
// Minified bundle | ||
{ | ||
plugins: [ | ||
// Resolve bare module specifiers to relative paths | ||
resolve(), | ||
// Minify HTML template literals | ||
minifyHTML(), | ||
// Minify JS | ||
terser({ | ||
ecma: 2020, | ||
format: { | ||
comments: false | ||
} | ||
}), | ||
// Print bundle summary | ||
summary(), | ||
// Visualize bundle size | ||
visualizer({ | ||
filename: 'dist/js-tree.bundle.min-stats.html' | ||
}) | ||
], | ||
input: 'src/js-tree.js', | ||
output: [ | ||
{ | ||
file: 'dist/js-tree.bundle.min.js', | ||
name: 'esupJsTree', | ||
format: 'umd' | ||
} | ||
], | ||
preserveEntrySignatures: 'strict' | ||
} | ||
] |
219175
15
2060
174
24