@kong-ui-public/split-pane 0.3.9 → 0.3.10-pr.3054.c6b7bee29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong/icons"),require("vue-router"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","@kong/icons","vue-router","@kong-ui-public/i18n"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R["kong-ui-public-split-pane"]={},R.Vue,R.KongIcons,R.VueRouter,R["kong-ui-public-i18n"]))})(this,(function(R,e,X,Z,F){"use strict";const J="260px",A="500px";function H(t,i){return e.getCurrentScope()?(e.onScopeDispose(t,i),!0):!1}const Q=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Y=t=>t!=null,ee=Object.prototype.toString,te=t=>ee.call(t)==="[object Object]",ne=()=>{};function D(t){return Array.isArray(t)?t:[t]}function ie(t){return e.getCurrentInstance()}function ae(t,i=!0,r){ie()?e.onMounted(t,r):i?t():e.nextTick(t)}function oe(t,i,r){return e.watch(t,i,{...r,immediate:!0})}const L=Q?window:void 0;function x(t){var i;const r=e.toValue(t);return(i=r==null?void 0:r.$el)!==null&&i!==void 0?i:r}function z(...t){const i=(n,a,s,o)=>(n.addEventListener(a,s,o),()=>n.removeEventListener(a,s,o)),r=e.computed(()=>{const n=D(e.toValue(t[0])).filter(a=>a!=null);return n.every(a=>typeof a!="string")?n:void 0});return oe(()=>{var n,a;return[(n=(a=r.value)===null||a===void 0?void 0:a.map(s=>x(s)))!==null&&n!==void 0?n:[L].filter(s=>s!=null),D(e.toValue(r.value?t[1]:t[0])),D(e.unref(r.value?t[2]:t[1])),e.toValue(r.value?t[3]:t[2])]},([n,a,s,o],c,p)=>{if(!(n!=null&&n.length)||!(a!=null&&a.length)||!(s!=null&&s.length))return;const h=te(o)?{...o}:o,d=n.flatMap(l=>a.flatMap(u=>s.map(g=>i(l,u,g,h))));p(()=>{d.forEach(l=>l())})},{flush:"post"})}function le(){const t=e.shallowRef(!1),i=e.getCurrentInstance();return i&&e.onMounted(()=>{t.value=!0},i),t}function U(t){const i=le();return e.computed(()=>(i.value,!!t()))}function se(t,i,r={}){const{window:n=L,...a}=r;let s;const o=U(()=>n&&"MutationObserver"in n),c=()=>{s&&(s.disconnect(),s=void 0)},p=e.watch(e.computed(()=>{const l=D(e.toValue(t)).map(x).filter(Y);return new Set(l)}),l=>{c(),o.value&&l.size&&(s=new MutationObserver(i),l.forEach(u=>s.observe(u,a)))},{immediate:!0,flush:"post"}),h=()=>s==null?void 0:s.takeRecords(),d=()=>{p(),c()};return H(d),{isSupported:o,stop:d,takeRecords:h}}function re(t,i,r={}){const{window:n=L,document:a=n==null?void 0:n.document,flush:s="sync"}=r;if(!n||!a)return ne;let o;const c=d=>{o==null||o(),o=d},p=e.watchEffect(()=>{const d=x(t);if(d){const{stop:l}=se(a,u=>{u.map(g=>[...g.removedNodes]).flat().some(g=>g===d||g.contains(d))&&i(u)},{window:n,childList:!0,subtree:!0});c(l)}},{flush:s}),h=()=>{p(),c()};return H(h),h}function ce(t,i,r={}){const{window:n=L,...a}=r;let s;const o=U(()=>n&&"ResizeObserver"in n),c=()=>{s&&(s.disconnect(),s=void 0)},p=e.watch(e.computed(()=>{const d=e.toValue(t);return Array.isArray(d)?d.map(l=>x(l)):[x(d)]}),d=>{if(c(),o.value&&n){s=new ResizeObserver(i);for(const l of d)l&&s.observe(l,a)}},{immediate:!0,flush:"post"}),h=()=>{c(),p()};return H(h),{isSupported:o,stop:h}}function j(t,i={}){const{delayEnter:r=0,delayLeave:n=0,triggerOnRemoval:a=!1,window:s=L}=i,o=e.shallowRef(!1);let c;const p=h=>{const d=h?r:n;c&&(clearTimeout(c),c=void 0),d?c=setTimeout(()=>o.value=h,d):o.value=h};return s&&(z(t,"mouseenter",()=>p(!0),{passive:!0}),z(t,"mouseleave",()=>p(!1),{passive:!0}),a&&re(e.computed(()=>x(t)),()=>p(!1))),o}function de(t,i={width:0,height:0},r={}){const{window:n=L,box:a="content-box"}=r,s=e.computed(()=>{var l;return(l=x(t))===null||l===void 0||(l=l.namespaceURI)===null||l===void 0?void 0:l.includes("svg")}),o=e.shallowRef(i.width),c=e.shallowRef(i.height),{stop:p}=ce(t,([l])=>{const u=a==="border-box"?l.borderBoxSize:a==="content-box"?l.contentBoxSize:l.devicePixelContentBoxSize;if(n&&s.value){const g=x(t);if(g){const b=g.getBoundingClientRect();o.value=b.width,c.value=b.height}}else if(u){const g=D(u);o.value=g.reduce((b,{inlineSize:E})=>b+E,0),c.value=g.reduce((b,{blockSize:E})=>b+E,0)}else o.value=l.contentRect.width,c.value=l.contentRect.height},r);ae(()=>{const l=x(t);l&&(o.value="offsetWidth"in l?l.offsetWidth:i.width,c.value="offsetHeight"in l?l.offsetHeight:i.height)});const h=e.watch(()=>x(t),l=>{o.value=l?i.width:0,c.value=l?i.height:0});function d(){p(),h()}return{width:o,height:c,stop:d}}const G="20px",N=e.ref(!1),_=e.ref(!1),S=e.ref(!0),I=e.ref(0);function K(t){const i=(t==null?void 0:t.verticalNavRef)||e.ref(null),r=(t==null?void 0:t.innerPanesContainerRef)||e.ref(null),n=(t==null?void 0:t.paneLeftRef)||e.ref(null),a=(t==null?void 0:t.paneCenterRef)||e.ref(null),s=(t==null?void 0:t.paneRightRef)||e.ref(null),o=f=>{var m,k,P,w,C;switch(f){case"verticalNav":return((m=i.value)==null?void 0:m.offsetWidth)||0;case"innerPanesContainer":return((k=r.value)==null?void 0:k.offsetWidth)||0;case"paneLeft":return((P=n.value)==null?void 0:P.offsetWidth)||0;case"paneCenter":return((w=a.value)==null?void 0:w.offsetWidth)||0;case"paneRight":return((C=s.value)==null?void 0:C.offsetWidth)||0;default:return 0}},c=e.ref(50),p=e.ref(0),h=e.ref(0),d=e.ref(0),l=e.ref(0),u=f=>{if(a.value){if(f){a.value.style.width=`${f}%`,I.value=o("paneCenter");return}else(typeof c.value!="number"||!isFinite(c.value))&&(c.value=38);a.value.style.width=`${c.value}%`,I.value=o("paneCenter")}},g=()=>{var f;a.value&&((f=s.value)==null?void 0:f.style.display)==="none"?(a.value.style.flex="1",u(100)):(a.value&&(a.value.style.flex=""),u())},b=()=>{var P;if(!r.value||!a.value)return;const f=100,m=o("innerPanesContainer")-o("verticalNav")-o("paneLeft")-f,k=c.value/100*o("innerPanesContainer");if(k<f?c.value=f/o("innerPanesContainer")*100:k>m&&(c.value=m/o("innerPanesContainer")*100),a.value&&s.value&&((P=s.value)==null?void 0:P.style.display)==="none"){u(100);return}u()},E=f=>{!a.value||f.button!==0||(_.value=!0,p.value=f.clientX,h.value=a.value.offsetWidth||0)},v=f=>{if(!_.value||!r.value||!a.value)return;const m=r.value.offsetWidth,k=f.clientX-p.value,w=(h.value+k)/m*100,C=100/m*100,V=(m-100)/m*100;c.value=Math.min(Math.max(C,w),V),u()},y=()=>{_.value=!1},W=f=>{!n.value||!S.value||f.button!==0||(N.value=!0,d.value=f.clientX,l.value=n.value.offsetWidth||0)},M=f=>{if(!N.value||!n.value)return;let m=l.value+(f.clientX-d.value);const k=Number(J.replace(/px$/i,"")),P=Number(A.replace(/px$/i,""));m<k&&(m=k),m>P&&(m=P),n.value.style.width=`${m}px`,d.value=f.clientX,l.value=m,I.value=o("paneCenter")},T=()=>{N.value=!1},B=()=>{_.value||b()},$=async()=>{S.value=!S.value};return z(window,"resize",B),e.onMounted(async()=>{await e.nextTick(),a.value&&(b(),await e.nextTick(),u(),requestAnimationFrame(()=>{I.value=o("paneCenter")}))}),z(document,"mousemove",f=>{_.value&&v(f),N.value&&M(f)}),z(document,"mouseup",()=>{_.value&&y(),N.value&&T()}),{isDraggingPaneLeft:e.readonly(N),isDraggingInnerPanes:e.readonly(_),startDraggingInnerPanes:E,refreshInnerPaneSizes:g,paneLeftExpanded:e.readonly(S),togglePaneLeft:$,startDraggingPaneLeft:W,centerPaneWidth:I}}const fe={actions:{return:"Return",collapse_panel:"Collapse panel",expand_panel:"Expand panel",drag_to_resize:"Click and drag to resize"}};function q(){const t=F.createI18n("en-us",fe);return{i18n:t,i18nT:F.i18nTComponent(t)}}const ue={class:"kong-ui-public-split-pane-vertical-navigation"},pe={class:"split-pane-nav"},he={class:"top"},ge={class:"bottom"},me=e.defineComponent({__name:"VerticalNavigation",props:{paneLeftWidth:{default:0},paneLeftVisible:{type:Boolean,default:!0},items:{default:()=>[]}},setup(t){e.useCssVars(u=>({c4231b96:d.value}));const{i18n:i}=q(),r=Z.useRouter(),{paneLeftExpanded:n,togglePaneLeft:a,isDraggingPaneLeft:s,isDraggingInnerPanes:o}=K(),c=e.ref(!1),p=e.ref(!1),h=e.computed(()=>c.value||s.value||o.value),d=e.computed(()=>`${t.paneLeftWidth-8}px`),l=u=>{n.value||a(),!u.active&&u.to&&r.push(u.to)};return e.onMounted(async()=>{await e.nextTick(),await new Promise(u=>setTimeout(u,500)),p.value=!0}),(u,g)=>{const b=e.resolveComponent("KButton"),E=e.resolveComponent("KTooltip");return e.openBlock(),e.createElementBlock("div",ue,[e.createElementVNode("nav",pe,[e.createElementVNode("div",he,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,v=>(e.openBlock(),e.createBlock(E,{key:v.tooltip,"kpop-attributes":{offset:"10px"},label:v.tooltip,placement:"right"},{default:e.withCtx(()=>[e.createVNode(b,{appearance:"none","aria-label":v.tooltip,class:e.normalizeClass(["split-pane-nav-item",{active:v.active}]),"data-testid":`kong-ui-public-split-pane-vertical-navigation-nav-item-${v.testid}`,icon:"",size:"large",style:{cursor:"pointer"},to:v.to,onClickCapture:e.withModifiers(y=>l(v),["prevent"])},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(v.icon),{decorative:"",size:e.unref(G)},null,8,["size"]))]),_:2},1032,["aria-label","class","data-testid","to","onClickCapture"])]),_:2},1032,["label"]))),128))]),e.createElementVNode("div",ge,[t.paneLeftVisible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["toggle-left-panel-control",{expanded:e.unref(n),"disable-animation":!p.value||e.unref(s)||e.unref(o)}]),onTransitionend:g[0]||(g[0]=e.withModifiers(v=>c.value=!1,["self"])),onTransitionstart:g[1]||(g[1]=e.withModifiers(v=>c.value=!0,["self"]))},[(e.openBlock(),e.createBlock(E,{key:String(e.unref(n)),"kpop-attributes":e.unref(n)?void 0:{offset:"10px"},label:h.value?void 0:e.unref(n)?e.unref(i).t("actions.collapse_panel"):e.unref(i).t("actions.expand_panel"),placement:e.unref(n)?"left":"right"},{default:e.withCtx(()=>[e.createVNode(b,{appearance:"none","aria-controls":"left-pane","aria-expanded":e.unref(n),"aria-label":e.unref(n)?e.unref(i).t("actions.collapse_panel"):e.unref(i).t("actions.expand_panel"),class:"split-pane-nav-item toggle-left-panel","data-testid":"kong-ui-public-split-pane-toggle-left-panel-button",icon:"",size:"large",onClick:e.unref(a)},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(n)?e.unref(X.ChevronDoubleLeftIcon):e.unref(X.ChevronDoubleRightIcon)),{decorative:"",size:e.unref(G)},null,8,["size"]))]),_:1},8,["aria-expanded","aria-label","onClick"])]),_:1},8,["kpop-attributes","label","placement"]))],34)):e.createCommentVNode("",!0)])])])}}}),O=(t,i)=>{const r=t.__vccOpts||t;for(const[n,a]of i)r[n]=a;return r},be=O(me,[["__scopeId","data-v-2261cf1d"]]),ve={class:"split-pane-container"},we={class:"split-pane-container-inner"},Ce={class:"panes"},ke=["aria-hidden","tabindex"],Re=["title"],Pe={class:"split-pane-container-inner-content"},xe=["aria-hidden","tabindex"],Ee=["title"],_e=["aria-hidden","tabindex"],ye=O(e.defineComponent({__name:"SplitPane",props:{resizable:{type:Boolean,default:!0},showResizeHandle:{type:Boolean,default:!0},showNavigation:{type:Boolean,default:!0},navigationItems:{default:()=>[]},paneLeft:{default:()=>({visible:!0,maxWidth:A})},paneCenter:{default:()=>({visible:!0,maxWidth:"50%"})},paneRight:{default:()=>({visible:!0,maxWidth:"50%"})}},setup(t){e.useCssVars(w=>({v49e30752:n.value,v2075cf60:a.value,v8d772a96:s.value}));const i=e.useSlots(),r=w=>w==="left"?t.paneLeft.maxWidth!==void 0?t.paneLeft.maxWidth:A:w==="center"?t.resizable?"none":t.paneCenter.maxWidth!==void 0?t.paneCenter.maxWidth:"50%":w==="right"?t.resizable?"none":t.paneRight.maxWidth!==void 0?t.paneRight.maxWidth:"50%":"none",n=e.computed(()=>r("left")),a=e.computed(()=>r("center")),s=e.computed(()=>r("right")),o=e.useTemplateRef("verticalNavRef"),c=e.useTemplateRef("innerPanesContainerRef"),p=e.useTemplateRef("paneLeftRef"),h=e.useTemplateRef("paneCenterRef"),d=e.useTemplateRef("paneRightRef"),l=e.useTemplateRef("paneLeftDivider"),u=e.useTemplateRef("innerPanesDivider"),{startDraggingInnerPanes:g,startDraggingPaneLeft:b,refreshInnerPaneSizes:E,paneLeftExpanded:v,isDraggingPaneLeft:y,isDraggingInnerPanes:W}=K({verticalNavRef:o,innerPanesContainerRef:c,paneLeftRef:p,paneCenterRef:h,paneRightRef:d}),{i18n:M}=q(),T=e.computed(()=>!!i["pane-left"]&&t.paneLeft.visible!==!1&&v.value),B=e.computed(()=>!!i["pane-center"]&&t.paneCenter.visible!==!1),$=e.computed(()=>!!i["pane-right"]&&t.paneRight.visible!==!1),f=e.computed(()=>t.resizable&&t.showResizeHandle&&!!i["pane-center"]&&t.paneCenter.visible!==!1&&!!i["pane-right"]&&t.paneRight.visible!==!1),m=j(l),k=j(u),{width:P}=de(p);return e.watch(()=>t.paneRight.visible,async()=>{t.resizable&&(await e.nextTick(),E())},{flush:"post"}),(w,C)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["kong-ui-public-split-pane",{"has-navigation":t.showNavigation}]),"data-testid":"split-pane"},[e.createElementVNode("div",ve,[t.showNavigation?(e.openBlock(),e.createBlock(be,{key:0,ref_key:"verticalNavRef",ref:o,items:t.navigationItems,"pane-left-visible":t.paneLeft.visible!==!1,"pane-left-width":e.unref(P)},null,8,["items","pane-left-visible","pane-left-width"])):e.createCommentVNode("",!0),e.createElementVNode("div",we,[e.createElementVNode("div",Ce,[e.createElementVNode("div",{ref_key:"paneLeftRef",ref:p,"aria-hidden":T.value?void 0:"true",class:e.normalizeClass(["split-pane-left",[{expanded:e.unref(v),"show-resize-border":e.unref(m)},{"is-dragging-pane-left":e.unref(y)},{"is-dragging-pane":e.unref(y)||e.unref(W)}]]),"data-testid":"split-pane-left",tabindex:T.value?0:-1},[e.renderSlot(w.$slots,"pane-left",{},void 0,!0)],10,ke),T.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"paneLeftDivider",ref:l,class:"split-pane-resize-divider left","data-testid":"split-pane-resize-divider-left",tabindex:"0",title:e.unref(M).t("actions.drag_to_resize"),onMousedown:C[0]||(C[0]=(...V)=>e.unref(b)&&e.unref(b)(...V))},[...C[2]||(C[2]=[e.createElementVNode("div",{class:"split-pane-drag-handle"},null,-1)])],40,Re)):e.createCommentVNode("",!0),e.createElementVNode("div",Pe,[i.toolbar?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["split-pane-toolbar-container",{"has-resize-divider-left":T.value}]),"data-testid":"split-pane-toolbar"},[e.renderSlot(w.$slots,"toolbar",{},void 0,!0)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerPanesContainerRef",ref:c,class:"split-pane-inner-panes"},[e.withDirectives(e.createElementVNode("div",{ref_key:"paneCenterRef",ref:h,"aria-hidden":B.value?void 0:"true",class:e.normalizeClass(["split-pane-center",[{"has-resize-divider-left":T.value},{"has-resize-divider-right":f.value},{"is-dragging-pane":e.unref(y)||e.unref(W)}]]),"data-testid":"split-pane-center",tabindex:B.value?0:-1},[e.renderSlot(w.$slots,"pane-center",{},void 0,!0)],10,xe),[[e.vShow,B.value]]),f.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"innerPanesDivider",ref:u,class:"split-pane-resize-divider right","data-testid":"split-pane-resize-divider-right",tabindex:"0",title:e.unref(M).t("actions.drag_to_resize"),onMousedown:C[1]||(C[1]=(...V)=>e.unref(g)&&e.unref(g)(...V))},[...C[3]||(C[3]=[e.createElementVNode("div",{class:"split-pane-drag-handle"},null,-1)])],40,Ee)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("div",{ref_key:"paneRightRef",ref:d,"aria-hidden":$.value?void 0:"true",class:e.normalizeClass(["split-pane-right",[{"has-toolbar":!!i.toolbar},{"show-resize-border":e.unref(k)},{"is-dragging-inner-panes":e.unref(W)},{"is-dragging-pane":e.unref(y)||e.unref(W)}]]),"data-testid":"split-pane-right",tabindex:$.value?0:-1},[e.renderSlot(w.$slots,"pane-right",{},void 0,!0)],10,_e),[[e.vShow,$.value]])],512)])])])])],2))}}),[["__scopeId","data-v-e368f52f"]]),Te={},Le={class:"kong-ui-public-split-pane-toolbar","data-testid":"kong-ui-public-split-pane-toolbar"},Ne={class:"left","data-testid":"split-toolbar-left"},We={key:0,class:"center","data-testid":"split-toolbar-center"},De={key:1,class:"right","data-testid":"split-toolbar-right"};function ze(t,i){return e.openBlock(),e.createElementBlock("div",Le,[e.createElementVNode("div",Ne,[e.renderSlot(t.$slots,"left",{},void 0,!0)]),t.$slots.center?(e.openBlock(),e.createElementBlock("div",We,[e.renderSlot(t.$slots,"center",{},void 0,!0)])):e.createCommentVNode("",!0),t.$slots.right?(e.openBlock(),e.createElementBlock("div",De,[e.renderSlot(t.$slots,"right",{},void 0,!0)])):e.createCommentVNode("",!0)])}const Ie=O(Te,[["render",ze],["__scopeId","data-v-44b95676"]]);R.SplitPane=ye,R.SplitToolbar=Ie,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong/icons"),require("vue-router"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","@kong/icons","vue-router","@kong-ui-public/i18n"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R["kong-ui-public-split-pane"]={},R.Vue,R.KongIcons,R.VueRouter,R["kong-ui-public-i18n"]))})(this,function(R,e,X,Q,F){"use strict";const Y="260px",O="500px",j="50%",K="50%";function A(t,i){return e.getCurrentScope()?(e.onScopeDispose(t,i),!0):!1}const ee=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const te=t=>t!=null,ne=Object.prototype.toString,ie=t=>ne.call(t)==="[object Object]",ae=()=>{};function T(t){return Array.isArray(t)?t:[t]}function oe(t){return e.getCurrentInstance()}function le(t,i=!0,r){oe()?e.onMounted(t,r):i?t():e.nextTick(t)}function se(t,i,r){return e.watch(t,i,{...r,immediate:!0})}const N=ee?window:void 0;function P(t){var i;const r=e.toValue(t);return(i=r==null?void 0:r.$el)!==null&&i!==void 0?i:r}function B(...t){const i=(n,a,s,o)=>(n.addEventListener(a,s,o),()=>n.removeEventListener(a,s,o)),r=e.computed(()=>{const n=T(e.toValue(t[0])).filter(a=>a!=null);return n.every(a=>typeof a!="string")?n:void 0});return se(()=>{var n,a;return[(n=(a=r.value)===null||a===void 0?void 0:a.map(s=>P(s)))!==null&&n!==void 0?n:[N].filter(s=>s!=null),T(e.toValue(r.value?t[1]:t[0])),T(e.unref(r.value?t[2]:t[1])),e.toValue(r.value?t[3]:t[2])]},([n,a,s,o],c,p)=>{if(!(n!=null&&n.length)||!(a!=null&&a.length)||!(s!=null&&s.length))return;const h=ie(o)?{...o}:o,d=n.flatMap(l=>a.flatMap(u=>s.map(g=>i(l,u,g,h))));p(()=>{d.forEach(l=>l())})},{flush:"post"})}function re(){const t=e.shallowRef(!1),i=e.getCurrentInstance();return i&&e.onMounted(()=>{t.value=!0},i),t}function q(t){const i=re();return e.computed(()=>(i.value,!!t()))}function ce(t,i,r={}){const{window:n=N,...a}=r;let s;const o=q(()=>n&&"MutationObserver"in n),c=()=>{s&&(s.disconnect(),s=void 0)},p=e.watch(e.computed(()=>{const l=T(e.toValue(t)).map(P).filter(te);return new Set(l)}),l=>{c(),o.value&&l.size&&(s=new MutationObserver(i),l.forEach(u=>s.observe(u,a)))},{immediate:!0,flush:"post"}),h=()=>s==null?void 0:s.takeRecords(),d=()=>{p(),c()};return A(d),{isSupported:o,stop:d,takeRecords:h}}function de(t,i,r={}){const{window:n=N,document:a=n==null?void 0:n.document,flush:s="sync"}=r;if(!n||!a)return ae;let o;const c=d=>{o==null||o(),o=d},p=e.watchEffect(()=>{const d=P(t);if(d){const{stop:l}=ce(a,u=>{u.map(g=>[...g.removedNodes]).flat().some(g=>g===d||g.contains(d))&&i(u)},{window:n,childList:!0,subtree:!0});c(l)}},{flush:s}),h=()=>{p(),c()};return A(h),h}function fe(t,i,r={}){const{window:n=N,...a}=r;let s;const o=q(()=>n&&"ResizeObserver"in n),c=()=>{s&&(s.disconnect(),s=void 0)},p=e.watch(e.computed(()=>{const d=e.toValue(t);return Array.isArray(d)?d.map(l=>P(l)):[P(d)]}),d=>{if(c(),o.value&&n){s=new ResizeObserver(i);for(const l of d)l&&s.observe(l,a)}},{immediate:!0,flush:"post"}),h=()=>{c(),p()};return A(h),{isSupported:o,stop:h}}function U(t,i={}){const{delayEnter:r=0,delayLeave:n=0,triggerOnRemoval:a=!1,window:s=N}=i,o=e.shallowRef(!1);let c;const p=h=>{const d=h?r:n;c&&(clearTimeout(c),c=void 0),d?c=setTimeout(()=>o.value=h,d):o.value=h};return s&&(B(t,"mouseenter",()=>p(!0),{passive:!0}),B(t,"mouseleave",()=>p(!1),{passive:!0}),a&&de(e.computed(()=>P(t)),()=>p(!1))),o}function ue(t,i={width:0,height:0},r={}){const{window:n=N,box:a="content-box"}=r,s=e.computed(()=>{var l;return(l=P(t))===null||l===void 0||(l=l.namespaceURI)===null||l===void 0?void 0:l.includes("svg")}),o=e.shallowRef(i.width),c=e.shallowRef(i.height),{stop:p}=fe(t,([l])=>{const u=a==="border-box"?l.borderBoxSize:a==="content-box"?l.contentBoxSize:l.devicePixelContentBoxSize;if(n&&s.value){const g=P(t);if(g){const b=g.getBoundingClientRect();o.value=b.width,c.value=b.height}}else if(u){const g=T(u);o.value=g.reduce((b,{inlineSize:y})=>b+y,0),c.value=g.reduce((b,{blockSize:y})=>b+y,0)}else o.value=l.contentRect.width,c.value=l.contentRect.height},r);le(()=>{const l=P(t);l&&(o.value="offsetWidth"in l?l.offsetWidth:i.width,c.value="offsetHeight"in l?l.offsetHeight:i.height)});const h=e.watch(()=>P(t),l=>{o.value=l?i.width:0,c.value=l?i.height:0});function d(){p(),h()}return{width:o,height:c,stop:d}}const G="20px",_=e.ref(!1),E=e.ref(!1),S=e.ref(!0),$=e.ref(0);function Z(t){const i=(t==null?void 0:t.verticalNavRef)||e.ref(null),r=(t==null?void 0:t.innerPanesContainerRef)||e.ref(null),n=(t==null?void 0:t.paneLeftRef)||e.ref(null),a=(t==null?void 0:t.paneCenterRef)||e.ref(null),s=(t==null?void 0:t.paneRightRef)||e.ref(null),o=f=>{var m,C,x,w,k;switch(f){case"verticalNav":return((m=i.value)==null?void 0:m.offsetWidth)||0;case"innerPanesContainer":return((C=r.value)==null?void 0:C.offsetWidth)||0;case"paneLeft":return((x=n.value)==null?void 0:x.offsetWidth)||0;case"paneCenter":return((w=a.value)==null?void 0:w.offsetWidth)||0;case"paneRight":return((k=s.value)==null?void 0:k.offsetWidth)||0;default:return 0}},c=e.ref(50),p=e.ref(0),h=e.ref(0),d=e.ref(0),l=e.ref(0),u=f=>{if(a.value){if(f){a.value.style.width=`${f}%`,$.value=o("paneCenter");return}else(typeof c.value!="number"||!isFinite(c.value))&&(c.value=38);a.value.style.width=`${c.value}%`,$.value=o("paneCenter")}},g=()=>{var f;a.value&&((f=s.value)==null?void 0:f.style.display)==="none"?(a.value.style.flex="1",u(100)):(a.value&&(a.value.style.flex=""),u())},b=()=>{var x;if(!r.value||!a.value)return;const f=100,m=o("innerPanesContainer")-o("verticalNav")-o("paneLeft")-f,C=c.value/100*o("innerPanesContainer");if(C<f?c.value=f/o("innerPanesContainer")*100:C>m&&(c.value=m/o("innerPanesContainer")*100),a.value&&s.value&&((x=s.value)==null?void 0:x.style.display)==="none"){u(100);return}u()},y=f=>{!a.value||f.button!==0||(E.value=!0,p.value=f.clientX,h.value=a.value.offsetWidth||0)},v=f=>{if(!E.value||!r.value||!a.value)return;const m=r.value.offsetWidth,C=f.clientX-p.value,w=(h.value+C)/m*100,k=100/m*100,I=(m-100)/m*100;c.value=Math.min(Math.max(k,w),I),u()},L=()=>{E.value=!1},z=f=>{!n.value||!S.value||f.button!==0||(_.value=!0,d.value=f.clientX,l.value=n.value.offsetWidth||0)},M=f=>{if(!_.value||!n.value)return;let m=l.value+(f.clientX-d.value);const C=Number(Y.replace(/px$/i,"")),x=Number(O.replace(/px$/i,""));m<C&&(m=C),m>x&&(m=x),n.value.style.width=`${m}px`,d.value=f.clientX,l.value=m,$.value=o("paneCenter")},W=()=>{_.value=!1},D=()=>{E.value||b()},V=async()=>{S.value=!S.value};return B(window,"resize",D),e.onMounted(async()=>{await e.nextTick(),a.value&&(b(),await e.nextTick(),u(),requestAnimationFrame(()=>{$.value=o("paneCenter")}))}),B(document,"mousemove",f=>{E.value&&v(f),_.value&&M(f)}),B(document,"mouseup",()=>{E.value&&L(),_.value&&W()}),{isDraggingPaneLeft:e.readonly(_),isDraggingInnerPanes:e.readonly(E),startDraggingInnerPanes:y,refreshInnerPaneSizes:g,paneLeftExpanded:e.readonly(S),togglePaneLeft:V,startDraggingPaneLeft:z,centerPaneWidth:$}}const pe={actions:{return:"Return",collapse_panel:"Collapse panel",expand_panel:"Expand panel",drag_to_resize:"Click and drag to resize"}};function J(){const t=F.createI18n("en-us",pe);return{i18n:t,i18nT:F.i18nTComponent(t)}}const he={class:"kong-ui-public-split-pane-vertical-navigation"},ge={class:"split-pane-nav"},me={class:"top"},be={class:"bottom"},ve=e.defineComponent({__name:"VerticalNavigation",props:{paneLeftWidth:{default:0},paneLeftVisible:{type:Boolean,default:!0},items:{default:()=>[]}},setup(t){e.useCssVars(u=>({c4231b96:d.value}));const{i18n:i}=J(),r=Q.useRouter(),{paneLeftExpanded:n,togglePaneLeft:a,isDraggingPaneLeft:s,isDraggingInnerPanes:o}=Z(),c=e.ref(!1),p=e.ref(!1),h=e.computed(()=>c.value||s.value||o.value),d=e.computed(()=>`${t.paneLeftWidth-8}px`),l=u=>{n.value||a(),!u.active&&u.to&&r.push(u.to)};return e.onMounted(async()=>{await e.nextTick(),await new Promise(u=>setTimeout(u,500)),p.value=!0}),(u,g)=>{const b=e.resolveComponent("KButton"),y=e.resolveComponent("KTooltip");return e.openBlock(),e.createElementBlock("div",he,[e.createElementVNode("nav",ge,[e.createElementVNode("div",me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,v=>(e.openBlock(),e.createBlock(y,{key:v.tooltip,"kpop-attributes":{offset:"10px"},label:v.tooltip,placement:"right"},{default:e.withCtx(()=>[e.createVNode(b,{appearance:"none","aria-label":v.tooltip,class:e.normalizeClass(["split-pane-nav-item",{active:v.active}]),"data-testid":`kong-ui-public-split-pane-vertical-navigation-nav-item-${v.testid}`,icon:"",size:"large",style:{cursor:"pointer"},to:v.to,onClickCapture:e.withModifiers(L=>l(v),["prevent"])},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(v.icon),{decorative:"",size:e.unref(G)},null,8,["size"]))]),_:2},1032,["aria-label","class","data-testid","to","onClickCapture"])]),_:2},1032,["label"]))),128))]),e.createElementVNode("div",be,[t.paneLeftVisible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["toggle-left-panel-control",{expanded:e.unref(n),"disable-animation":!p.value||e.unref(s)||e.unref(o)}]),onTransitionend:g[0]||(g[0]=e.withModifiers(v=>c.value=!1,["self"])),onTransitionstart:g[1]||(g[1]=e.withModifiers(v=>c.value=!0,["self"]))},[(e.openBlock(),e.createBlock(y,{key:String(e.unref(n)),"kpop-attributes":e.unref(n)?void 0:{offset:"10px"},label:h.value?void 0:e.unref(n)?e.unref(i).t("actions.collapse_panel"):e.unref(i).t("actions.expand_panel"),placement:e.unref(n)?"left":"right"},{default:e.withCtx(()=>[e.createVNode(b,{appearance:"none","aria-controls":"left-pane","aria-expanded":e.unref(n),"aria-label":e.unref(n)?e.unref(i).t("actions.collapse_panel"):e.unref(i).t("actions.expand_panel"),class:"split-pane-nav-item toggle-left-panel","data-testid":"kong-ui-public-split-pane-toggle-left-panel-button",icon:"",size:"large",onClick:e.unref(a)},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(n)?e.unref(X.ChevronDoubleLeftIcon):e.unref(X.ChevronDoubleRightIcon)),{decorative:"",size:e.unref(G)},null,8,["size"]))]),_:1},8,["aria-expanded","aria-label","onClick"])]),_:1},8,["kpop-attributes","label","placement"]))],34)):e.createCommentVNode("",!0)])])])}}}),H=(t,i)=>{const r=t.__vccOpts||t;for(const[n,a]of i)r[n]=a;return r},we=H(ve,[["__scopeId","data-v-2261cf1d"]]),ke={class:"split-pane-container"},Ce={class:"split-pane-container-inner"},Re={class:"panes"},xe=["aria-hidden","tabindex"],Pe=["title"],ye={class:"split-pane-container-inner-content"},Ee=["aria-hidden","tabindex"],Le=["title"],We=["aria-hidden","tabindex"],Ne=H(e.defineComponent({__name:"SplitPane",props:{resizable:{type:Boolean,default:!0},showResizeHandle:{type:Boolean,default:!0},showNavigation:{type:Boolean,default:!0},navigationItems:{default:()=>[]},paneLeft:{default:()=>({visible:!0,maxWidth:O})},paneCenter:{default:()=>({visible:!0,maxWidth:j})},paneRight:{default:()=>({visible:!0,maxWidth:K})}},setup(t){e.useCssVars(w=>({v49e30752:n.value,v2075cf60:a.value,v8d772a96:s.value}));const i=e.useSlots(),r=w=>w==="left"?t.paneLeft.maxWidth!==void 0?t.paneLeft.maxWidth:O:w==="center"?t.resizable?"none":t.paneCenter.maxWidth!==void 0?t.paneCenter.maxWidth:j:w==="right"?t.resizable?"none":t.paneRight.maxWidth!==void 0?t.paneRight.maxWidth:K:"none",n=e.computed(()=>r("left")),a=e.computed(()=>r("center")),s=e.computed(()=>r("right")),o=e.useTemplateRef("verticalNavRef"),c=e.useTemplateRef("innerPanesContainerRef"),p=e.useTemplateRef("paneLeftRef"),h=e.useTemplateRef("paneCenterRef"),d=e.useTemplateRef("paneRightRef"),l=e.useTemplateRef("paneLeftDivider"),u=e.useTemplateRef("innerPanesDivider"),{startDraggingInnerPanes:g,startDraggingPaneLeft:b,refreshInnerPaneSizes:y,paneLeftExpanded:v,isDraggingPaneLeft:L,isDraggingInnerPanes:z}=Z({verticalNavRef:o,innerPanesContainerRef:c,paneLeftRef:p,paneCenterRef:h,paneRightRef:d}),{i18n:M}=J(),W=e.computed(()=>!!i["pane-left"]&&t.paneLeft.visible!==!1&&v.value),D=e.computed(()=>!!i["pane-center"]&&t.paneCenter.visible!==!1),V=e.computed(()=>!!i["pane-right"]&&t.paneRight.visible!==!1),f=e.computed(()=>t.resizable&&t.showResizeHandle&&!!i["pane-center"]&&t.paneCenter.visible!==!1&&!!i["pane-right"]&&t.paneRight.visible!==!1),m=U(l),C=U(u),{width:x}=ue(p);return e.watch(()=>t.paneRight.visible,async()=>{t.resizable&&(await e.nextTick(),y())},{flush:"post"}),(w,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["kong-ui-public-split-pane",{"has-navigation":t.showNavigation}]),"data-testid":"split-pane"},[e.createElementVNode("div",ke,[t.showNavigation?(e.openBlock(),e.createBlock(we,{key:0,ref_key:"verticalNavRef",ref:o,items:t.navigationItems,"pane-left-visible":t.paneLeft.visible!==!1,"pane-left-width":e.unref(x)},null,8,["items","pane-left-visible","pane-left-width"])):e.createCommentVNode("",!0),e.createElementVNode("div",Ce,[e.createElementVNode("div",Re,[e.createElementVNode("div",{ref_key:"paneLeftRef",ref:p,"aria-hidden":W.value?void 0:"true",class:e.normalizeClass(["split-pane-left",[{expanded:e.unref(v),"show-resize-border":e.unref(m)},{"is-dragging-pane-left":e.unref(L)},{"is-dragging-pane":e.unref(L)||e.unref(z)}]]),"data-testid":"split-pane-left",tabindex:W.value?0:-1},[e.renderSlot(w.$slots,"pane-left",{},void 0,!0)],10,xe),W.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"paneLeftDivider",ref:l,class:"split-pane-resize-divider left","data-testid":"split-pane-resize-divider-left",tabindex:"0",title:e.unref(M).t("actions.drag_to_resize"),onMousedown:k[0]||(k[0]=(...I)=>e.unref(b)&&e.unref(b)(...I))},[...k[2]||(k[2]=[e.createElementVNode("div",{class:"split-pane-drag-handle"},null,-1)])],40,Pe)):e.createCommentVNode("",!0),e.createElementVNode("div",ye,[i.toolbar?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["split-pane-toolbar-container",{"has-resize-divider-left":W.value}]),"data-testid":"split-pane-toolbar"},[e.renderSlot(w.$slots,"toolbar",{},void 0,!0)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerPanesContainerRef",ref:c,class:"split-pane-inner-panes"},[e.withDirectives(e.createElementVNode("div",{ref_key:"paneCenterRef",ref:h,"aria-hidden":D.value?void 0:"true",class:e.normalizeClass(["split-pane-center",[{"has-resize-divider-left":W.value},{"has-resize-divider-right":f.value},{"is-dragging-pane":e.unref(L)||e.unref(z)}]]),"data-testid":"split-pane-center",tabindex:D.value?0:-1},[e.renderSlot(w.$slots,"pane-center",{},void 0,!0)],10,Ee),[[e.vShow,D.value]]),f.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"innerPanesDivider",ref:u,class:"split-pane-resize-divider right","data-testid":"split-pane-resize-divider-right",tabindex:"0",title:e.unref(M).t("actions.drag_to_resize"),onMousedown:k[1]||(k[1]=(...I)=>e.unref(g)&&e.unref(g)(...I))},[...k[3]||(k[3]=[e.createElementVNode("div",{class:"split-pane-drag-handle"},null,-1)])],40,Le)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("div",{ref_key:"paneRightRef",ref:d,"aria-hidden":V.value?void 0:"true",class:e.normalizeClass(["split-pane-right",[{"has-toolbar":!!i.toolbar},{"show-resize-border":e.unref(C)},{"is-dragging-inner-panes":e.unref(z)},{"is-dragging-pane":e.unref(L)||e.unref(z)}]]),"data-testid":"split-pane-right",tabindex:V.value?0:-1},[e.renderSlot(w.$slots,"pane-right",{},void 0,!0)],10,We),[[e.vShow,V.value]])],512)])])])])],2))}}),[["__scopeId","data-v-e368f52f"]]),_e={},ze={class:"kong-ui-public-split-pane-toolbar","data-testid":"kong-ui-public-split-pane-toolbar"},Te={class:"left","data-testid":"split-toolbar-left"},Be={key:0,class:"center","data-testid":"split-toolbar-center"},$e={key:1,class:"right","data-testid":"split-toolbar-right"};function De(t,i){return e.openBlock(),e.createElementBlock("div",ze,[e.createElementVNode("div",Te,[e.renderSlot(t.$slots,"left",{},void 0,!0)]),t.$slots.center?(e.openBlock(),e.createElementBlock("div",Be,[e.renderSlot(t.$slots,"center",{},void 0,!0)])):e.createCommentVNode("",!0),t.$slots.right?(e.openBlock(),e.createElementBlock("div",$e,[e.renderSlot(t.$slots,"right",{},void 0,!0)])):e.createCommentVNode("",!0)])}const Ve=H(_e,[["render",De],["__scopeId","data-v-44b95676"]]);R.SplitPane=Ne,R.SplitToolbar=Ve,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/split-pane",
3
- "version": "0.3.9",
3
+ "version": "0.3.10-pr.3054.c6b7bee29.0",
4
4
  "type": "module",
5
5
  "description": "A shared SplitPane layout component for Vue 3 applications.",
6
6
  "main": "./dist/split-pane.umd.js",
@@ -45,7 +45,7 @@
45
45
  "errorLimit": "200KB"
46
46
  },
47
47
  "peerDependencies": {
48
- "@kong/icons": "^1.47.0",
48
+ "@kong/icons": "^1.48.0",
49
49
  "@kong/kongponents": ">=9.42.0 <10.0.0",
50
50
  "vue": "^3.5.27",
51
51
  "@kong-ui-public/i18n": "^2.4.6"