@kodaris/krubble-app-components 1.0.66 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/krubble-app.bundled.js +17 -1
- package/dist/krubble-app.bundled.js.map +1 -1
- package/dist/krubble-app.bundled.min.js +6 -6
- package/dist/krubble-app.bundled.min.js.map +1 -1
- package/dist/krubble-app.umd.js +17 -1
- package/dist/krubble-app.umd.js.map +1 -1
- package/dist/krubble-app.umd.min.js +3 -3
- package/dist/krubble-app.umd.min.js.map +1 -1
- package/dist/scaffold.d.ts +6 -0
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +17 -1
- package/dist/scaffold.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
const E=globalThis,I=E.trustedTypes,S=I?I.createPolicy("lit-html",{createHTML:t=>t}):void 0,C="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,N="?"+A,D=`<${N}>`,z=document,M=()=>z.createComment(""),
|
|
17
|
+
const E=globalThis,I=E.trustedTypes,S=I?I.createPolicy("lit-html",{createHTML:t=>t}):void 0,C="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,N="?"+A,D=`<${N}>`,z=document,M=()=>z.createComment(""),T=t=>null===t||"object"!=typeof t&&"function"!=typeof t,P=Array.isArray,R="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,L=/>/g,H=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,q=/"/g,X=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),F=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),Y=new WeakMap,V=z.createTreeWalker(z,129);function K(t,e){if(!P(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}const Q=(t,e)=>{const i=t.length-1,s=[];let a,r=2===e?"<svg>":3===e?"<math>":"",n=U;for(let e=0;e<i;e++){const i=t[e];let o,l,d=-1,c=0;for(;c<i.length&&(n.lastIndex=c,l=n.exec(i),null!==l);)c=n.lastIndex,n===U?"!--"===l[1]?n=O:void 0!==l[1]?n=L:void 0!==l[2]?(X.test(l[2])&&(a=RegExp("</"+l[2],"g")),n=H):void 0!==l[3]&&(n=H):n===H?">"===l[0]?(n=a??U,d=-1):void 0===l[1]?d=-2:(d=n.lastIndex-l[2].length,o=l[1],n=void 0===l[3]?H:'"'===l[3]?q:j):n===q||n===j?n=H:n===O||n===L?n=U:(n=H,a=void 0);const h=n===H&&t[e+1].startsWith("/>")?" ":"";r+=n===U?i+D:d>=0?(s.push(o),i.slice(0,d)+C+i.slice(d)+A+h):i+A+(-2===d?e:h)}return[K(t,r+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]};class G{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let a=0,r=0;const n=t.length-1,o=this.parts,[l,d]=Q(t,e);if(this.el=G.createElement(l,i),V.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(s=V.nextNode())&&o.length<n;){if(1===s.nodeType){if(s.hasAttributes())for(const t of s.getAttributeNames())if(t.endsWith(C)){const e=d[r++],i=s.getAttribute(t).split(A),n=/([.?@])?(.*)/.exec(e);o.push({type:1,index:a,name:n[2],strings:i,ctor:"."===n[1]?it:"?"===n[1]?st:"@"===n[1]?at:et}),s.removeAttribute(t)}else t.startsWith(A)&&(o.push({type:6,index:a}),s.removeAttribute(t));if(X.test(s.tagName)){const t=s.textContent.split(A),e=t.length-1;if(e>0){s.textContent=I?I.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],M()),V.nextNode(),o.push({type:2,index:++a});s.append(t[e],M())}}}else if(8===s.nodeType)if(s.data===N)o.push({type:2,index:a});else{let t=-1;for(;-1!==(t=s.data.indexOf(A,t+1));)o.push({type:7,index:a}),t+=A.length-1}a++}}static createElement(t,e){const i=z.createElement("template");return i.innerHTML=t,i}}function J(t,e,i=t,s){if(e===F)return e;let a=void 0!==s?i._$Co?.[s]:i._$Cl;const r=T(e)?void 0:e._$litDirective$;return a?.constructor!==r&&(a?._$AO?.(!1),void 0===r?a=void 0:(a=new r(t),a._$AT(t,i,s)),void 0!==s?(i._$Co??=[])[s]=a:i._$Cl=a),void 0!==a&&(e=J(t,a._$AS(t,e.values),a,s)),e}class Z{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=(t?.creationScope??z).importNode(e,!0);V.currentNode=s;let a=V.nextNode(),r=0,n=0,o=i[0];for(;void 0!==o;){if(r===o.index){let e;2===o.type?e=new tt(a,a.nextSibling,this,t):1===o.type?e=new o.ctor(a,o.name,o.strings,this,t):6===o.type&&(e=new rt(a,this,t)),this._$AV.push(e),o=i[++n]}r!==o?.index&&(a=V.nextNode(),r++)}return V.currentNode=z,s}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class tt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=W,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}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=J(this,t,e),T(t)?t===W||null==t||""===t?(this._$AH!==W&&this._$AR(),this._$AH=W):t!==this._$AH&&t!==F&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>P(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==W&&T(this._$AH)?this._$AA.nextSibling.data=t:this.T(z.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,s="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=G.createElement(K(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(e);else{const t=new Z(s,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=Y.get(t.strings);return void 0===e&&Y.set(t.strings,e=new G(t)),e}k(t){P(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const a of t)s===e.length?e.push(i=new tt(this.O(M()),this.O(M()),this,this.options)):i=e[s],i._$AI(a),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class et{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,a){this.type=1,this._$AH=W,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=a,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=W}_$AI(t,e=this,i,s){const a=this.strings;let r=!1;if(void 0===a)t=J(this,t,e,0),r=!T(t)||t!==this._$AH&&t!==F,r&&(this._$AH=t);else{const s=t;let n,o;for(t=a[0],n=0;n<a.length-1;n++)o=J(this,s[i+n],e,n),o===F&&(o=this._$AH[n]),r||=!T(o)||o!==this._$AH[n],o===W?t=W:t!==W&&(t+=(o??"")+a[n+1]),this._$AH[n]=o}r&&!s&&this.j(t)}j(t){t===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class it extends et{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===W?void 0:t}}class st extends et{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==W)}}class at extends et{constructor(t,e,i,s,a){super(t,e,i,s,a),this.type=5}_$AI(t,e=this){if((t=J(this,t,e,0)??W)===F)return;const i=this._$AH,s=t===W&&i!==W||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,a=t!==W&&(i===W||s);s&&this.element.removeEventListener(this.name,this,i),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class rt{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){J(this,t)}}const nt=E.litHtmlPolyfillSupport;nt?.(G,tt),(E.litHtmlVersions??=[]).push("3.3.2");const ot=globalThis;
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
@@ -198,7 +198,7 @@ function vt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
|
|
|
198
198
|
.btn-save:hover {
|
|
199
199
|
background: #d4f472;
|
|
200
200
|
}
|
|
201
|
-
`,kt([gt()],$t.prototype,"label",void 0),kt([gt()],$t.prototype,"icon",void 0),kt([gt()],$t.prototype,"url",void 0),kt([gt()],$t.prototype,"active",void 0),$t=kt([ct("kr-nav-item-edit")],$t);var Et=function(t,e,i,s){var a,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(n=(r<3?a(n):r>3?a(e,i,n):a(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};t.Scaffold=class extends lt{constructor(){super(),this.defaultNavItemIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',this.navItemsExpanded=new Set,this.navQuery="",this.activeNavItemId=null,this.isNavScrolled=!1,this.isNavOpened="false"!==localStorage.getItem("kr-scaffold-nav-opened"),this.isEditing=!1,this.isUserMenuOpen=!1,this.pref={nav:{}},this.draggedNavItemId=null,this.navItemDropTargetId=null,this.navItemDropPosition="above",this.pendingRequests=0,this.originalFetch=null,this.originalXhrOpen=null,this.navItemDragPreview=null,this.navItemDragStartY=0,this.isNavItemDragging=!1,this.navItemDragExpandTimeout=null,this.navInitialized=!1,this.logo="",this.label="",this.homeUrl="/",this.scheme="light",this.nav=[],this.navIconsDisplayed=!1,this.navExpanded=!1,this.user=null,this.subbar=!1,this.navEnabled=!0,this.breadcrumbs=[],this.boundHandleMouseMove=this.handleMouseMove.bind(this),this.boundHandleMouseUp=this.handleMouseUp.bind(this)}connectedCallback(){super.connectedCallback(),this.loadPref(),this.installFetchInterceptor()}updated(t){super.updated(t),t.has("nav")&&this.nav.length>0&&(this.updateActiveNavItem(),this.navExpanded&&!this.navInitialized&&(this.navInitialized=!0,this.getComputedNav().filter((t=>"group"===t.type)).forEach((t=>this.navItemsExpanded.add(t.id)))))}disconnectedCallback(){super.disconnectedCallback(),this.uninstallFetchInterceptor()}installFetchInterceptor(){if(this.originalFetch)return;const t=this;this.originalFetch=window.fetch.bind(window);const e=this.originalFetch;window.fetch=function(...i){return t.pendingRequests++,e(...i).finally((()=>{t.pendingRequests--}))},this.originalXhrOpen=XMLHttpRequest.prototype.open;const i=this.originalXhrOpen;XMLHttpRequest.prototype.open=function(e,s,a=!0,r,n){return t.pendingRequests++,this.addEventListener("loadend",(()=>{t.pendingRequests--}),{once:!0}),i.call(this,e,s,a,r,n)}}uninstallFetchInterceptor(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null)}resolveUrl(t){if(!t.url)return"#";if(t.external)return t.url;const e=t.url.startsWith("/")?t.url.slice(1):t.url,i=document.querySelector("base")?.getAttribute("href")||"/";return(i.endsWith("/")?i:i+"/")+e}getComputedNav(){const t=[];return this.nav.forEach(((e,i)=>{const s=this.pref.nav[e.id];t.push({...e,...s,order:s?.order??e.order??i,parentId:s?.parentId??null}),"group"===e.type&&e.children&&e.children.forEach(((i,s)=>{const a=this.pref.nav[i.id];t.push({...i,...a,order:a?.order??i.order??s,parentId:void 0!==a?.parentId?a.parentId:e.id})}))})),Object.entries(this.pref.nav).forEach((([e,i])=>{e.startsWith("custom")&&i.type&&i.label&&t.push({id:e,type:i.type,label:i.label,icon:i.icon,url:i.url,active:i.active,order:i.order??t.length,parentId:i.parentId??null})})),t}getNavItemChildren(t){let e=this.getComputedNav().filter((e=>e.parentId===t)).sort(((t,e)=>t.order-e.order));if(this.isEditing||(e=e.filter((t=>!1!==t.active))),this.navQuery){const i=this.navQuery.toLowerCase(),s=this.getComputedNav();if(null!==t){const a=s.find((e=>e.id===t));if(a?.label.toLowerCase().includes(i))return e}e=e.filter((t=>"group"===t.type?t.label.toLowerCase().includes(i)||s.some((e=>e.parentId===t.id&&!1!==e.active&&e.label.toLowerCase().includes(i))):t.label.toLowerCase().includes(i)))}return e}handleNavQueryChange(t){this.navQuery=t.target.value,this.navQuery?this.getComputedNav().forEach((t=>{"group"===t.type&&this.navItemsExpanded.add(t.id)})):this.navItemsExpanded.clear()}handleNavQueryClear(){this.navQuery="",this.navItemsExpanded.clear()}handleMenuClick(){this.isNavOpened=!this.isNavOpened,localStorage.setItem("kr-scaffold-nav-opened",String(this.isNavOpened))}handleNavHeaderClick(){this.activeNavItemId=null;const t=new CustomEvent("nav-item-click",{detail:{item:{url:this.homeUrl}},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t),t.defaultPrevented||(window.location.href=this.homeUrl)}handleNavScroll(t){this.isNavScrolled=t.target.scrollTop>0}toggleNavItem(t){const e=this.shadowRoot?.querySelector(`.nav-item[data-id="${t}"]`),i=e?.nextElementSibling;i&&(this.navItemsExpanded.has(t)?(this.navItemsExpanded.delete(t),i.animate([{height:`${i.scrollHeight}px`},{height:"0px"}],{duration:300,easing:"ease-in-out"}).onfinish=()=>{i.classList.remove("nav-group--expanded")}):(this.navItemsExpanded.add(t),i.classList.add("nav-group--expanded"),i.animate([{height:"0px"},{height:`${i.scrollHeight}px`}],{duration:300,easing:"ease-in-out"})),this.requestUpdate())}handleNavItemClick(t,e){if("group"===e.type)this.toggleNavItem(e.id);else{if(t.ctrlKey||t.metaKey||1===t.button)return;this.activeNavItemId=e.id;const i=new CustomEvent("nav-item-click",{detail:{item:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&t.preventDefault()}}updateActiveNavItem(){const t=window.location.pathname,e=this.getComputedNav().filter((t=>"item"===t.type&&t.url));let i=null,s=0;for(const a of e){const e=this.resolveUrl(a);t.startsWith(e)&&e.length>s&&(i=a,s=e.length)}i?(this.activeNavItemId=i.id,i.parentId&&this.navItemsExpanded.add(i.parentId)):this.activeNavItemId=null}startEditing(){this.isEditing=!0}cancelEditing(){this.isEditing=!1,this.loadPref()}resetPref(){this.pref.nav={}}savePref(){const t=this.pref.uuid?`/api/system/preference/json/scaffold/${this.pref.uuid}?global=true`:"/api/system/preference/json/scaffold?global=true";i.Http.fetch({url:t,method:this.pref.uuid?"PUT":"POST",body:JSON.stringify({nav:this.pref.nav})}).then((t=>t.json())).then((t=>{this.pref=t.data,this.isEditing=!1})).catch((t=>{console.error("Failed to save nav customizations:",t)}))}loadPref(){i.Http.fetch({url:"/api/system/preference/json/scaffold?global=true",method:"GET"}).then((t=>t.json())).then((t=>{const e=t?.data?.[0];e&&(this.pref=e)})).catch((()=>{}))}handleNavItemContextMenu(t,i){this.isEditing&&(t.preventDefault(),e.ContextMenu.open({x:t.clientX,y:t.clientY,items:[{id:"edit",label:"Edit Item"},{id:"divider-1",label:"",divider:!0},{id:"add-above",label:"Add Item Above"},{id:"add-below",label:"Add Item Below"}]}).then((t=>{if(t)switch(t.id){case"edit":this.openNavItemEdit(i);break;case"add-above":this.addNavItem(i,"above");break;case"add-below":this.addNavItem(i,"below")}})))}openNavItemEdit(t){e.Dialog.open($t,{data:t}).afterClosed().then((e=>{const i=e;i&&(this.pref.nav[t.id]||(this.pref.nav[t.id]={}),this.pref.nav[t.id]={...this.pref.nav[t.id],...i},this.requestUpdate())}))}addNavItem(t,e){const i=`custom-${Date.now()}`,s=this.getComputedNav().filter((e=>e.parentId===t.parentId)).sort(((t,e)=>t.order-e.order)),a=s.findIndex((e=>e.id===t.id)),r="above"===e?a:a+1;s.forEach(((t,e)=>{e>=r&&(this.pref.nav[t.id]||(this.pref.nav[t.id]={}),this.pref.nav[t.id].order=e+1)}));const n={id:i,type:"item",label:"New Item",order:r,parentId:t.parentId,active:!0};this.pref.nav[i]=n,this.requestUpdate(),this.openNavItemEdit(n)}handleNavItemMouseDown(t,e){this.isEditing&&(t.preventDefault(),this.draggedNavItemId=e.id,this.navItemDragStartY=t.clientY,this.isNavItemDragging=!1,document.addEventListener("mousemove",this.boundHandleMouseMove),document.addEventListener("mouseup",this.boundHandleMouseUp))}handleMouseMove(t){if(this.draggedNavItemId){if(!this.isNavItemDragging&&Math.abs(t.clientY-this.navItemDragStartY)>5){this.isNavItemDragging=!0,this.classList.add("kr-scaffold--dragging");const e=this.getComputedNav().find((t=>t.id===this.draggedNavItemId));e&&(this.navItemDragPreview=document.createElement("div"),this.navItemDragPreview.className="nav-item-drag-preview",this.navItemDragPreview.textContent=e.label,this.navItemDragPreview.style.left=`${t.clientX+10}px`,this.navItemDragPreview.style.top=t.clientY-20+"px",this.shadowRoot?.appendChild(this.navItemDragPreview))}this.isNavItemDragging&&(this.navItemDragPreview&&(this.navItemDragPreview.style.left=`${t.clientX+10}px`,this.navItemDragPreview.style.top=t.clientY-20+"px"),this.updateNavItemDropTarget(t))}}handleMouseUp(){document.removeEventListener("mousemove",this.boundHandleMouseMove),document.removeEventListener("mouseup",this.boundHandleMouseUp),this.isNavItemDragging&&this.navItemDropTargetId&&this.executeNavItemDrop(),this.draggedNavItemId=null,this.navItemDropTargetId=null,this.isNavItemDragging=!1,this.classList.remove("kr-scaffold--dragging"),this.navItemDragPreview&&(this.navItemDragPreview.remove(),this.navItemDragPreview=null),this.clearNavItemDragExpandTimeout(),this.requestUpdate()}updateNavItemDropTarget(t){const e=this.shadowRoot?.querySelectorAll(".nav-item[data-id]");if(!e)return;let i=!1;e.forEach((e=>{const s=e.getBoundingClientRect(),a=e.getAttribute("data-id");if(!a||a===this.draggedNavItemId)return;if(t.clientX<s.left||t.clientX>s.right||t.clientY<s.top||t.clientY>s.bottom)return;const r=this.getComputedNav().find((t=>t.id===a));if(!r)return;const n=t.clientY-s.top;let o;"group"===r.type?n<s.height/3?(o="above",this.clearNavItemDragExpandTimeout()):n>2*s.height/3?(o="below",this.clearNavItemDragExpandTimeout()):(o="center",this.navItemsExpanded.has(r.id)||this.navItemDragExpandTimeout||this.expandNavGroupOnDrag(r.id)):(o=n<s.height/2?"above":"below",this.clearNavItemDragExpandTimeout());const l="center"===o?r.id:r.parentId,d=this.getComputedNav().find((t=>t.id===this.draggedNavItemId));if(l===this.draggedNavItemId||"group"===d?.type&&null!==l)return this.navItemDropTargetId=null,void this.clearNavItemDragExpandTimeout();this.navItemDropTargetId=r.id,this.navItemDropPosition=o,i=!0})),i||(this.navItemDropTargetId=null,this.clearNavItemDragExpandTimeout()),this.requestUpdate()}clearNavItemDragExpandTimeout(){this.navItemDragExpandTimeout&&(clearTimeout(this.navItemDragExpandTimeout),this.navItemDragExpandTimeout=null)}expandNavGroupOnDrag(t){this.navItemDragExpandTimeout=window.setTimeout((()=>{this.navItemDropTargetId===t&&"center"===this.navItemDropPosition&&(this.navItemsExpanded.add(t),this.requestUpdate()),this.navItemDragExpandTimeout=null}),500)}executeNavItemDrop(){if(!this.draggedNavItemId||!this.navItemDropTargetId)return;const t=this.getComputedNav(),e=t.find((t=>t.id===this.draggedNavItemId)),i=t.find((t=>t.id===this.navItemDropTargetId));if(!e||!i)return;let s;if("center"===this.navItemDropPosition&&"group"===i.type){if(i.id===this.draggedNavItemId)return;s=i.id}else s=i.parentId;if(s===this.draggedNavItemId)return;const a=t.filter((t=>t.parentId===s&&t.id!==this.draggedNavItemId)).sort(((t,e)=>t.order-e.order)),r=this.pref.nav;let n;if("center"===this.navItemDropPosition)n=a.length>0?Math.max(...a.map((t=>t.order)))+1:0;else{const t=a.findIndex((t=>t.id===i.id));n=-1===t?0:"above"===this.navItemDropPosition?t:t+1,a.forEach(((t,e)=>{r[t.id]||(r[t.id]={}),r[t.id].order=e>=n?e+1:e}))}r[this.draggedNavItemId]||(r[this.draggedNavItemId]={}),r[this.draggedNavItemId].order=n,r[this.draggedNavItemId].parentId=s,this.pref.nav=r,this.requestUpdate()}toggleUserMenu(){this.isUserMenuOpen=!this.isUserMenuOpen}closeUserMenu(){this.isUserMenuOpen=!1}handleCustomize(){this.closeUserMenu(),this.startEditing()}renderNormalFooter(){if(!this.user)return W;const t=this.user.name.split(" ").map((t=>t[0])).join("").toUpperCase().slice(0,2);return B`
|
|
201
|
+
`,kt([gt()],$t.prototype,"label",void 0),kt([gt()],$t.prototype,"icon",void 0),kt([gt()],$t.prototype,"url",void 0),kt([gt()],$t.prototype,"active",void 0),$t=kt([ct("kr-nav-item-edit")],$t);var Et=function(t,e,i,s){var a,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(n=(r<3?a(n):r>3?a(e,i,n):a(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};t.Scaffold=class extends lt{constructor(){super(),this.defaultNavItemIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',this.navItemsExpanded=new Set,this.navQuery="",this.activeNavItemId=null,this.isNavScrolled=!1,this.isNavOpened="false"!==localStorage.getItem("kr-scaffold-nav-opened"),this.isEditing=!1,this.isUserMenuOpen=!1,this.pref={nav:{}},this.draggedNavItemId=null,this.navItemDropTargetId=null,this.navItemDropPosition="above",this.pendingRequests=0,this.originalFetch=null,this.originalXhrOpen=null,this.navItemDragPreview=null,this.navItemDragStartY=0,this.isNavItemDragging=!1,this.navItemDragExpandTimeout=null,this.navInitialized=!1,this.logo="",this.label="",this.homeUrl="/",this.scheme="light",this.nav=[],this.navIconsDisplayed=!1,this.navExpanded=!1,this.user=null,this.subbar=!1,this.navEnabled=!0,this.userType="employee",this.breadcrumbs=[],this.boundHandleMouseMove=this.handleMouseMove.bind(this),this.boundHandleMouseUp=this.handleMouseUp.bind(this)}connectedCallback(){super.connectedCallback(),this.installFetchInterceptor()}firstUpdated(){this.loadPref()}updated(t){super.updated(t),t.has("nav")&&this.nav.length>0&&(this.updateActiveNavItem(),this.navExpanded&&!this.navInitialized&&(this.navInitialized=!0,this.getComputedNav().filter((t=>"group"===t.type)).forEach((t=>this.navItemsExpanded.add(t.id)))))}disconnectedCallback(){super.disconnectedCallback(),this.uninstallFetchInterceptor()}installFetchInterceptor(){if(this.originalFetch)return;const t=this;this.originalFetch=window.fetch.bind(window);const e=this.originalFetch;window.fetch=function(...i){return t.pendingRequests++,e(...i).finally((()=>{t.pendingRequests--}))},this.originalXhrOpen=XMLHttpRequest.prototype.open;const i=this.originalXhrOpen;XMLHttpRequest.prototype.open=function(e,s,a=!0,r,n){return t.pendingRequests++,this.addEventListener("loadend",(()=>{t.pendingRequests--}),{once:!0}),i.call(this,e,s,a,r,n)}}uninstallFetchInterceptor(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null)}resolveUrl(t){if(!t.url)return"#";if(t.external)return t.url;const e=t.url.startsWith("/")?t.url.slice(1):t.url,i=document.querySelector("base")?.getAttribute("href")||"/";return(i.endsWith("/")?i:i+"/")+e}getComputedNav(){const t=[];return this.nav.forEach(((e,i)=>{const s=this.pref.nav[e.id];t.push({...e,...s,order:s?.order??e.order??i,parentId:s?.parentId??null}),"group"===e.type&&e.children&&e.children.forEach(((i,s)=>{const a=this.pref.nav[i.id];t.push({...i,...a,order:a?.order??i.order??s,parentId:void 0!==a?.parentId?a.parentId:e.id})}))})),Object.entries(this.pref.nav).forEach((([e,i])=>{e.startsWith("custom")&&i.type&&i.label&&t.push({id:e,type:i.type,label:i.label,icon:i.icon,url:i.url,active:i.active,order:i.order??t.length,parentId:i.parentId??null})})),t}getNavItemChildren(t){let e=this.getComputedNav().filter((e=>e.parentId===t)).sort(((t,e)=>t.order-e.order));if(this.isEditing||(e=e.filter((t=>!1!==t.active))),this.navQuery){const i=this.navQuery.toLowerCase(),s=this.getComputedNav();if(null!==t){const a=s.find((e=>e.id===t));if(a?.label.toLowerCase().includes(i))return e}e=e.filter((t=>"group"===t.type?t.label.toLowerCase().includes(i)||s.some((e=>e.parentId===t.id&&!1!==e.active&&e.label.toLowerCase().includes(i))):t.label.toLowerCase().includes(i)))}return e}handleNavQueryChange(t){this.navQuery=t.target.value,this.navQuery?this.getComputedNav().forEach((t=>{"group"===t.type&&this.navItemsExpanded.add(t.id)})):this.navItemsExpanded.clear()}handleNavQueryClear(){this.navQuery="",this.navItemsExpanded.clear()}handleMenuClick(){this.isNavOpened=!this.isNavOpened,localStorage.setItem("kr-scaffold-nav-opened",String(this.isNavOpened))}handleNavHeaderClick(){this.activeNavItemId=null;const t=new CustomEvent("nav-item-click",{detail:{item:{url:this.homeUrl}},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t),t.defaultPrevented||(window.location.href=this.homeUrl)}handleNavScroll(t){this.isNavScrolled=t.target.scrollTop>0}toggleNavItem(t){const e=this.shadowRoot?.querySelector(`.nav-item[data-id="${t}"]`),i=e?.nextElementSibling;i&&(this.navItemsExpanded.has(t)?(this.navItemsExpanded.delete(t),i.animate([{height:`${i.scrollHeight}px`},{height:"0px"}],{duration:300,easing:"ease-in-out"}).onfinish=()=>{i.classList.remove("nav-group--expanded")}):(this.navItemsExpanded.add(t),i.classList.add("nav-group--expanded"),i.animate([{height:"0px"},{height:`${i.scrollHeight}px`}],{duration:300,easing:"ease-in-out"})),this.requestUpdate())}handleNavItemClick(t,e){if("group"===e.type)this.toggleNavItem(e.id);else{if(t.ctrlKey||t.metaKey||1===t.button)return;this.activeNavItemId=e.id;const i=new CustomEvent("nav-item-click",{detail:{item:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&t.preventDefault()}}updateActiveNavItem(){const t=window.location.pathname,e=this.getComputedNav().filter((t=>"item"===t.type&&t.url));let i=null,s=0;for(const a of e){const e=this.resolveUrl(a);t.startsWith(e)&&e.length>s&&(i=a,s=e.length)}i?(this.activeNavItemId=i.id,i.parentId&&this.navItemsExpanded.add(i.parentId)):this.activeNavItemId=null}startEditing(){this.isEditing=!0}cancelEditing(){this.isEditing=!1,this.loadPref()}resetPref(){this.pref.nav={}}savePref(){if("customer"===this.userType)return;const t=this.pref.uuid?`/api/system/preference/json/scaffold/${this.pref.uuid}?global=true`:"/api/system/preference/json/scaffold?global=true";i.Http.fetch({url:t,method:this.pref.uuid?"PUT":"POST",body:JSON.stringify({nav:this.pref.nav})}).then((t=>t.json())).then((t=>{this.pref=t.data,this.isEditing=!1})).catch((t=>{console.error("Failed to save nav customizations:",t)}))}loadPref(){"customer"!==this.userType&&i.Http.fetch({url:"/api/system/preference/json/scaffold?global=true",method:"GET"}).then((t=>t.json())).then((t=>{const e=t?.data?.[0];e&&(this.pref=e)})).catch((()=>{}))}handleNavItemContextMenu(t,i){this.isEditing&&(t.preventDefault(),e.ContextMenu.open({x:t.clientX,y:t.clientY,items:[{id:"edit",label:"Edit Item"},{id:"divider-1",label:"",divider:!0},{id:"add-above",label:"Add Item Above"},{id:"add-below",label:"Add Item Below"}]}).then((t=>{if(t)switch(t.id){case"edit":this.openNavItemEdit(i);break;case"add-above":this.addNavItem(i,"above");break;case"add-below":this.addNavItem(i,"below")}})))}openNavItemEdit(t){e.Dialog.open($t,{data:t}).afterClosed().then((e=>{const i=e;i&&(this.pref.nav[t.id]||(this.pref.nav[t.id]={}),this.pref.nav[t.id]={...this.pref.nav[t.id],...i},this.requestUpdate())}))}addNavItem(t,e){const i=`custom-${Date.now()}`,s=this.getComputedNav().filter((e=>e.parentId===t.parentId)).sort(((t,e)=>t.order-e.order)),a=s.findIndex((e=>e.id===t.id)),r="above"===e?a:a+1;s.forEach(((t,e)=>{e>=r&&(this.pref.nav[t.id]||(this.pref.nav[t.id]={}),this.pref.nav[t.id].order=e+1)}));const n={id:i,type:"item",label:"New Item",order:r,parentId:t.parentId,active:!0};this.pref.nav[i]=n,this.requestUpdate(),this.openNavItemEdit(n)}handleNavItemMouseDown(t,e){this.isEditing&&(t.preventDefault(),this.draggedNavItemId=e.id,this.navItemDragStartY=t.clientY,this.isNavItemDragging=!1,document.addEventListener("mousemove",this.boundHandleMouseMove),document.addEventListener("mouseup",this.boundHandleMouseUp))}handleMouseMove(t){if(this.draggedNavItemId){if(!this.isNavItemDragging&&Math.abs(t.clientY-this.navItemDragStartY)>5){this.isNavItemDragging=!0,this.classList.add("kr-scaffold--dragging");const e=this.getComputedNav().find((t=>t.id===this.draggedNavItemId));e&&(this.navItemDragPreview=document.createElement("div"),this.navItemDragPreview.className="nav-item-drag-preview",this.navItemDragPreview.textContent=e.label,this.navItemDragPreview.style.left=`${t.clientX+10}px`,this.navItemDragPreview.style.top=t.clientY-20+"px",this.shadowRoot?.appendChild(this.navItemDragPreview))}this.isNavItemDragging&&(this.navItemDragPreview&&(this.navItemDragPreview.style.left=`${t.clientX+10}px`,this.navItemDragPreview.style.top=t.clientY-20+"px"),this.updateNavItemDropTarget(t))}}handleMouseUp(){document.removeEventListener("mousemove",this.boundHandleMouseMove),document.removeEventListener("mouseup",this.boundHandleMouseUp),this.isNavItemDragging&&this.navItemDropTargetId&&this.executeNavItemDrop(),this.draggedNavItemId=null,this.navItemDropTargetId=null,this.isNavItemDragging=!1,this.classList.remove("kr-scaffold--dragging"),this.navItemDragPreview&&(this.navItemDragPreview.remove(),this.navItemDragPreview=null),this.clearNavItemDragExpandTimeout(),this.requestUpdate()}updateNavItemDropTarget(t){const e=this.shadowRoot?.querySelectorAll(".nav-item[data-id]");if(!e)return;let i=!1;e.forEach((e=>{const s=e.getBoundingClientRect(),a=e.getAttribute("data-id");if(!a||a===this.draggedNavItemId)return;if(t.clientX<s.left||t.clientX>s.right||t.clientY<s.top||t.clientY>s.bottom)return;const r=this.getComputedNav().find((t=>t.id===a));if(!r)return;const n=t.clientY-s.top;let o;"group"===r.type?n<s.height/3?(o="above",this.clearNavItemDragExpandTimeout()):n>2*s.height/3?(o="below",this.clearNavItemDragExpandTimeout()):(o="center",this.navItemsExpanded.has(r.id)||this.navItemDragExpandTimeout||this.expandNavGroupOnDrag(r.id)):(o=n<s.height/2?"above":"below",this.clearNavItemDragExpandTimeout());const l="center"===o?r.id:r.parentId,d=this.getComputedNav().find((t=>t.id===this.draggedNavItemId));if(l===this.draggedNavItemId||"group"===d?.type&&null!==l)return this.navItemDropTargetId=null,void this.clearNavItemDragExpandTimeout();this.navItemDropTargetId=r.id,this.navItemDropPosition=o,i=!0})),i||(this.navItemDropTargetId=null,this.clearNavItemDragExpandTimeout()),this.requestUpdate()}clearNavItemDragExpandTimeout(){this.navItemDragExpandTimeout&&(clearTimeout(this.navItemDragExpandTimeout),this.navItemDragExpandTimeout=null)}expandNavGroupOnDrag(t){this.navItemDragExpandTimeout=window.setTimeout((()=>{this.navItemDropTargetId===t&&"center"===this.navItemDropPosition&&(this.navItemsExpanded.add(t),this.requestUpdate()),this.navItemDragExpandTimeout=null}),500)}executeNavItemDrop(){if(!this.draggedNavItemId||!this.navItemDropTargetId)return;const t=this.getComputedNav(),e=t.find((t=>t.id===this.draggedNavItemId)),i=t.find((t=>t.id===this.navItemDropTargetId));if(!e||!i)return;let s;if("center"===this.navItemDropPosition&&"group"===i.type){if(i.id===this.draggedNavItemId)return;s=i.id}else s=i.parentId;if(s===this.draggedNavItemId)return;const a=t.filter((t=>t.parentId===s&&t.id!==this.draggedNavItemId)).sort(((t,e)=>t.order-e.order)),r=this.pref.nav;let n;if("center"===this.navItemDropPosition)n=a.length>0?Math.max(...a.map((t=>t.order)))+1:0;else{const t=a.findIndex((t=>t.id===i.id));n=-1===t?0:"above"===this.navItemDropPosition?t:t+1,a.forEach(((t,e)=>{r[t.id]||(r[t.id]={}),r[t.id].order=e>=n?e+1:e}))}r[this.draggedNavItemId]||(r[this.draggedNavItemId]={}),r[this.draggedNavItemId].order=n,r[this.draggedNavItemId].parentId=s,this.pref.nav=r,this.requestUpdate()}toggleUserMenu(){this.isUserMenuOpen=!this.isUserMenuOpen}closeUserMenu(){this.isUserMenuOpen=!1}handleCustomize(){this.closeUserMenu(),this.startEditing()}renderNormalFooter(){if(!this.user)return W;const t=this.user.name.split(" ").map((t=>t[0])).join("").toUpperCase().slice(0,2);return B`
|
|
202
202
|
<div class="user-menu-container">
|
|
203
203
|
${this.isUserMenuOpen?B`
|
|
204
204
|
<div class="user-menu">
|
|
@@ -1058,7 +1058,7 @@ function vt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
|
|
|
1058
1058
|
transform: scaleX(0.08);
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
|
-
`,Et([gt()],t.Scaffold.prototype,"navItemsExpanded",void 0),Et([gt()],t.Scaffold.prototype,"navQuery",void 0),Et([gt()],t.Scaffold.prototype,"activeNavItemId",void 0),Et([gt()],t.Scaffold.prototype,"isNavScrolled",void 0),Et([gt()],t.Scaffold.prototype,"isNavOpened",void 0),Et([gt()],t.Scaffold.prototype,"isEditing",void 0),Et([gt()],t.Scaffold.prototype,"isUserMenuOpen",void 0),Et([gt()],t.Scaffold.prototype,"pref",void 0),Et([gt()],t.Scaffold.prototype,"draggedNavItemId",void 0),Et([gt()],t.Scaffold.prototype,"navItemDropTargetId",void 0),Et([gt()],t.Scaffold.prototype,"navItemDropPosition",void 0),Et([gt()],t.Scaffold.prototype,"pendingRequests",void 0),Et([ut({type:String})],t.Scaffold.prototype,"logo",void 0),Et([ut({type:String})],t.Scaffold.prototype,"label",void 0),Et([ut({type:String,attribute:"home-url"})],t.Scaffold.prototype,"homeUrl",void 0),Et([ut({type:String,reflect:!0})],t.Scaffold.prototype,"scheme",void 0),Et([ut({type:Array})],t.Scaffold.prototype,"nav",void 0),Et([ut({type:Boolean,attribute:"nav-icons-displayed",reflect:!0})],t.Scaffold.prototype,"navIconsDisplayed",void 0),Et([ut({type:Boolean,attribute:"nav-expanded"})],t.Scaffold.prototype,"navExpanded",void 0),Et([ut({type:Object})],t.Scaffold.prototype,"user",void 0),Et([ut({type:Boolean})],t.Scaffold.prototype,"subbar",void 0),Et([ut({type:Boolean,attribute:"nav-enabled"})],t.Scaffold.prototype,"navEnabled",void 0),Et([ut({type:Array})],t.Scaffold.prototype,"breadcrumbs",void 0),t.Scaffold=Et([ct("kr-scaffold")],t.Scaffold);var It=function(t,e,i,s){var a,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(n=(r<3?a(n):r>3?a(e,i,n):a(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};t.ScreenNav=class extends lt{constructor(){super(...arguments),this.label="",this.subLabel="",this.navItems=[],this.activeId="",this.handlePopstate=()=>{this.syncActiveFromUrl()}}connectedCallback(){super.connectedCallback(),requestAnimationFrame((()=>this.syncActiveFromUrl())),window.addEventListener("popstate",this.handlePopstate)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopstate)}handleNavItemClick(t,e){const i=new CustomEvent("nav-item-click",{detail:{item:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&t.preventDefault(),this.activeId=e.id}syncActiveFromUrl(){const t=window.location.pathname,e=this.navItems.find((e=>!!e.url&&(e.url.startsWith("/")?t===e.url:t.endsWith("/"+e.url))));e&&(this.activeId=e.id)}render(){return B`
|
|
1061
|
+
`,Et([gt()],t.Scaffold.prototype,"navItemsExpanded",void 0),Et([gt()],t.Scaffold.prototype,"navQuery",void 0),Et([gt()],t.Scaffold.prototype,"activeNavItemId",void 0),Et([gt()],t.Scaffold.prototype,"isNavScrolled",void 0),Et([gt()],t.Scaffold.prototype,"isNavOpened",void 0),Et([gt()],t.Scaffold.prototype,"isEditing",void 0),Et([gt()],t.Scaffold.prototype,"isUserMenuOpen",void 0),Et([gt()],t.Scaffold.prototype,"pref",void 0),Et([gt()],t.Scaffold.prototype,"draggedNavItemId",void 0),Et([gt()],t.Scaffold.prototype,"navItemDropTargetId",void 0),Et([gt()],t.Scaffold.prototype,"navItemDropPosition",void 0),Et([gt()],t.Scaffold.prototype,"pendingRequests",void 0),Et([ut({type:String})],t.Scaffold.prototype,"logo",void 0),Et([ut({type:String})],t.Scaffold.prototype,"label",void 0),Et([ut({type:String,attribute:"home-url"})],t.Scaffold.prototype,"homeUrl",void 0),Et([ut({type:String,reflect:!0})],t.Scaffold.prototype,"scheme",void 0),Et([ut({type:Array})],t.Scaffold.prototype,"nav",void 0),Et([ut({type:Boolean,attribute:"nav-icons-displayed",reflect:!0})],t.Scaffold.prototype,"navIconsDisplayed",void 0),Et([ut({type:Boolean,attribute:"nav-expanded"})],t.Scaffold.prototype,"navExpanded",void 0),Et([ut({type:Object})],t.Scaffold.prototype,"user",void 0),Et([ut({type:Boolean})],t.Scaffold.prototype,"subbar",void 0),Et([ut({type:Boolean,attribute:"nav-enabled"})],t.Scaffold.prototype,"navEnabled",void 0),Et([ut({type:String,attribute:"user-type"})],t.Scaffold.prototype,"userType",void 0),Et([ut({type:Array})],t.Scaffold.prototype,"breadcrumbs",void 0),t.Scaffold=Et([ct("kr-scaffold")],t.Scaffold);var It=function(t,e,i,s){var a,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(n=(r<3?a(n):r>3?a(e,i,n):a(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};t.ScreenNav=class extends lt{constructor(){super(...arguments),this.label="",this.subLabel="",this.navItems=[],this.activeId="",this.handlePopstate=()=>{this.syncActiveFromUrl()}}connectedCallback(){super.connectedCallback(),requestAnimationFrame((()=>this.syncActiveFromUrl())),window.addEventListener("popstate",this.handlePopstate)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopstate)}handleNavItemClick(t,e){const i=new CustomEvent("nav-item-click",{detail:{item:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&t.preventDefault(),this.activeId=e.id}syncActiveFromUrl(){const t=window.location.pathname,e=this.navItems.find((e=>!!e.url&&(e.url.startsWith("/")?t===e.url:t.endsWith("/"+e.url))));e&&(this.activeId=e.id)}render(){return B`
|
|
1062
1062
|
<nav class="nav">
|
|
1063
1063
|
${this.label?B`
|
|
1064
1064
|
<div class="nav-header">
|