@govtechsg/sgds-web-component 3.21.2-rc.2 → 3.21.2-rc.3
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/components/Sidebar/index.umd.min.js +3 -1
- package/components/Sidebar/index.umd.min.js.map +1 -1
- package/components/Sidebar/sgds-sidebar-group.js +3 -1
- package/components/Sidebar/sgds-sidebar-group.js.map +1 -1
- package/components/index.umd.min.js +3 -1
- package/components/index.umd.min.js.map +1 -1
- package/custom-elements.json +1 -1
- package/index.umd.min.js +3 -1
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Sidebar/sgds-sidebar-group.cjs.js +3 -1
- package/react/components/Sidebar/sgds-sidebar-group.cjs.js.map +1 -1
- package/react/components/Sidebar/sgds-sidebar-group.js +3 -1
- package/react/components/Sidebar/sgds-sidebar-group.js.map +1 -1
|
@@ -2319,8 +2319,10 @@ window.ShadyDOM?.inUse&&!0===window.ShadyDOM?.noPatch&&window.ShadyDOM.wrap;
|
|
|
2319
2319
|
*/
|
|
2320
2320
|
const ft=()=>new mt;class mt{}const bt=Math.min,xt=Math.max,Zt=Math.round,yt=Math.floor,Ct=e=>({x:e,y:e}),_t={left:"right",right:"left",bottom:"top",top:"bottom"},Mt={start:"end",end:"start"};function Vt(e,t,i){return xt(e,bt(t,i))}function Ht(e,t){return"function"==typeof e?e(t):e}function At(e){return e.split("-")[0]}function $t(e){return e.split("-")[1]}function Bt(e){return"x"===e?"y":"x"}function kt(e){return"y"===e?"height":"width"}const Lt=new Set(["top","bottom"]);function St(e){return Lt.has(At(e))?"y":"x"}function Et(e){return Bt(St(e))}function Pt(e,t,i){void 0===i&&(i=!1);const l=$t(e),a=Et(e),s=kt(a);let o="x"===a?l===(i?"end":"start")?"right":"left":"start"===l?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Nt(o)),[o,Nt(o)]}function zt(e){return e.replace(/start|end/g,e=>Mt[e])}const Ot=["left","right"],Tt=["right","left"],Rt=["top","bottom"],It=["bottom","top"];function Dt(e,t,i,l){const a=$t(e);let s=function(e,t,i){switch(e){case"top":case"bottom":return i?t?Tt:Ot:t?Ot:Tt;case"left":case"right":return t?Rt:It;default:return[]}}(At(e),"start"===i,l);return a&&(s=s.map(e=>e+"-"+a),t&&(s=s.concat(s.map(zt)))),s}function Nt(e){return e.replace(/left|right|bottom|top/g,e=>_t[e])}function Ut(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function Wt(e){const{x:t,y:i,width:l,height:a}=e;return{width:l,height:a,top:i,left:t,right:t+l,bottom:i+a,x:t,y:i}}function qt(e,t,i){let{reference:l,floating:a}=e;const s=St(t),o=Et(t),r=kt(o),n=At(t),c="y"===s,d=l.x+l.width/2-a.width/2,h=l.y+l.height/2-a.height/2,v=l[r]/2-a[r]/2;let p;switch(n){case"top":p={x:d,y:l.y-a.height};break;case"bottom":p={x:d,y:l.y+l.height};break;case"right":p={x:l.x+l.width,y:h};break;case"left":p={x:l.x-a.width,y:h};break;default:p={x:l.x,y:l.y}}switch($t(t)){case"start":p[o]-=v*(i&&c?-1:1);break;case"end":p[o]+=v*(i&&c?-1:1)}return p}async function jt(e,t){var i;void 0===t&&(t={});const{x:l,y:a,platform:s,rects:o,elements:r,strategy:n}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:v=!1,padding:p=0}=Ht(t,e),g=Ut(p),u=r[v?"floating"===h?"reference":"floating":h],w=Wt(await s.getClippingRect({element:null==(i=await(null==s.isElement?void 0:s.isElement(u)))||i?u:u.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(r.floating)),boundary:c,rootBoundary:d,strategy:n})),f="floating"===h?{x:l,y:a,width:o.floating.width,height:o.floating.height}:o.reference,m=await(null==s.getOffsetParent?void 0:s.getOffsetParent(r.floating)),b=await(null==s.isElement?void 0:s.isElement(m))&&await(null==s.getScale?void 0:s.getScale(m))||{x:1,y:1},x=Wt(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:f,offsetParent:m,strategy:n}):f);return{top:(w.top-x.top+g.top)/b.y,bottom:(x.bottom-w.bottom+g.bottom)/b.y,left:(w.left-x.left+g.left)/b.x,right:(x.right-w.right+g.right)/b.x}}const Ft=new Set(["left","top"]);function Gt(){return"undefined"!=typeof window}function Kt(e){return Xt(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Yt(e){var t;return null==(t=(Xt(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Xt(e){return!!Gt()&&(e instanceof Node||e instanceof Jt(e).Node)}function Qt(e){return!!Gt()&&(e instanceof Element||e instanceof Jt(e).Element)}function ei(e){return!!Gt()&&(e instanceof HTMLElement||e instanceof Jt(e).HTMLElement)}function ti(e){return!(!Gt()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot)}const ii=new Set(["inline","contents"]);function li(e){const{overflow:t,overflowX:i,overflowY:l,display:a}=ui(e);return/auto|scroll|overlay|hidden|clip/.test(t+l+i)&&!ii.has(a)}const ai=new Set(["table","td","th"]);function si(e){return ai.has(Kt(e))}const oi=[":popover-open",":modal"];function ri(e){return oi.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const ni=["transform","translate","scale","rotate","perspective"],ci=["transform","translate","scale","rotate","perspective","filter"],di=["paint","layout","strict","content"];function hi(e){const t=vi(),i=Qt(e)?ui(e):e;return ni.some(e=>!!i[e]&&"none"!==i[e])||!!i.containerType&&"normal"!==i.containerType||!t&&!!i.backdropFilter&&"none"!==i.backdropFilter||!t&&!!i.filter&&"none"!==i.filter||ci.some(e=>(i.willChange||"").includes(e))||di.some(e=>(i.contain||"").includes(e))}function vi(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const pi=new Set(["html","body","#document"]);function gi(e){return pi.has(Kt(e))}function ui(e){return Jt(e).getComputedStyle(e)}function wi(e){return Qt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function fi(e){if("html"===Kt(e))return e;const t=e.assignedSlot||e.parentNode||ti(e)&&e.host||Yt(e);return ti(t)?t.host:t}function mi(e){const t=fi(e);return gi(t)?e.ownerDocument?e.ownerDocument.body:e.body:ei(t)&&li(t)?t:mi(t)}function bi(e,t,i){var l;void 0===t&&(t=[]),void 0===i&&(i=!0);const a=mi(e),s=a===(null==(l=e.ownerDocument)?void 0:l.body),o=Jt(a);if(s){const e=xi(o);return t.concat(o,o.visualViewport||[],li(a)?a:[],e&&i?bi(e):[])}return t.concat(a,bi(a,[],i))}function xi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Zi(e){const t=ui(e);let i=parseFloat(t.width)||0,l=parseFloat(t.height)||0;const a=ei(e),s=a?e.offsetWidth:i,o=a?e.offsetHeight:l,r=Zt(i)!==s||Zt(l)!==o;return r&&(i=s,l=o),{width:i,height:l,$:r}}function yi(e){return Qt(e)?e:e.contextElement}function Ci(e){const t=yi(e);if(!ei(t))return Ct(1);const i=t.getBoundingClientRect(),{width:l,height:a,$:s}=Zi(t);let o=(s?Zt(i.width):i.width)/l,r=(s?Zt(i.height):i.height)/a;return o&&Number.isFinite(o)||(o=1),r&&Number.isFinite(r)||(r=1),{x:o,y:r}}const _i=Ct(0);function Mi(e){const t=Jt(e);return vi()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:_i}function Vi(e,t,i,l){void 0===t&&(t=!1),void 0===i&&(i=!1);const a=e.getBoundingClientRect(),s=yi(e);let o=Ct(1);t&&(l?Qt(l)&&(o=Ci(l)):o=Ci(e));const r=function(e,t,i){return void 0===t&&(t=!1),!(!i||t&&i!==Jt(e))&&t}(s,i,l)?Mi(s):Ct(0);let n=(a.left+r.x)/o.x,c=(a.top+r.y)/o.y,d=a.width/o.x,h=a.height/o.y;if(s){const e=Jt(s),t=l&&Qt(l)?Jt(l):l;let i=e,a=xi(i);for(;a&&l&&t!==i;){const e=Ci(a),t=a.getBoundingClientRect(),l=ui(a),s=t.left+(a.clientLeft+parseFloat(l.paddingLeft))*e.x,o=t.top+(a.clientTop+parseFloat(l.paddingTop))*e.y;n*=e.x,c*=e.y,d*=e.x,h*=e.y,n+=s,c+=o,i=Jt(a),a=xi(i)}}return Wt({width:d,height:h,x:n,y:c})}function Hi(e,t){const i=wi(e).scrollLeft;return t?t.left+i:Vi(Yt(e)).left+i}function Ai(e,t){const i=e.getBoundingClientRect();return{x:i.left+t.scrollLeft-Hi(e,i),y:i.top+t.scrollTop}}const $i=new Set(["absolute","fixed"]);function Bi(e,t,i){let l;if("viewport"===t)l=function(e,t){const i=Jt(e),l=Yt(e),a=i.visualViewport;let s=l.clientWidth,o=l.clientHeight,r=0,n=0;if(a){s=a.width,o=a.height;const e=vi();(!e||e&&"fixed"===t)&&(r=a.offsetLeft,n=a.offsetTop)}const c=Hi(l);if(c<=0){const e=l.ownerDocument,t=e.body,i=getComputedStyle(t),a="CSS1Compat"===e.compatMode&&parseFloat(i.marginLeft)+parseFloat(i.marginRight)||0,o=Math.abs(l.clientWidth-t.clientWidth-a);o<=25&&(s-=o)}else c<=25&&(s+=c);return{width:s,height:o,x:r,y:n}}(e,i);else if("document"===t)l=function(e){const t=Yt(e),i=wi(e),l=e.ownerDocument.body,a=xt(t.scrollWidth,t.clientWidth,l.scrollWidth,l.clientWidth),s=xt(t.scrollHeight,t.clientHeight,l.scrollHeight,l.clientHeight);let o=-i.scrollLeft+Hi(e);const r=-i.scrollTop;return"rtl"===ui(l).direction&&(o+=xt(t.clientWidth,l.clientWidth)-a),{width:a,height:s,x:o,y:r}}(Yt(e));else if(Qt(t))l=function(e,t){const i=Vi(e,!0,"fixed"===t),l=i.top+e.clientTop,a=i.left+e.clientLeft,s=ei(e)?Ci(e):Ct(1);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:a*s.x,y:l*s.y}}(t,i);else{const i=Mi(e);l={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Wt(l)}function ki(e,t){const i=fi(e);return!(i===t||!Qt(i)||gi(i))&&("fixed"===ui(i).position||ki(i,t))}function Li(e,t,i){const l=ei(t),a=Yt(t),s="fixed"===i,o=Vi(e,!0,s,t);let r={scrollLeft:0,scrollTop:0};const n=Ct(0);function c(){n.x=Hi(a)}if(l||!l&&!s)if(("body"!==Kt(t)||li(a))&&(r=wi(t)),l){const e=Vi(t,!0,s,t);n.x=e.x+t.clientLeft,n.y=e.y+t.clientTop}else a&&c();s&&!l&&a&&c();const d=!a||l||s?Ct(0):Ai(a,r);return{x:o.left+r.scrollLeft-n.x-d.x,y:o.top+r.scrollTop-n.y-d.y,width:o.width,height:o.height}}function Si(e){return"static"===ui(e).position}function Ei(e,t){if(!ei(e)||"fixed"===ui(e).position)return null;if(t)return t(e);let i=e.offsetParent;return Yt(e)===i&&(i=i.ownerDocument.body),i}function Pi(e,t){const i=Jt(e);if(ri(e))return i;if(!ei(e)){let t=fi(e);for(;t&&!gi(t);){if(Qt(t)&&!Si(t))return t;t=fi(t)}return i}let l=Ei(e,t);for(;l&&si(l)&&Si(l);)l=Ei(l,t);return l&&gi(l)&&Si(l)&&!hi(l)?i:l||function(e){let t=fi(e);for(;ei(t)&&!gi(t);){if(hi(t))return t;if(ri(t))return null;t=fi(t)}return null}(e)||i}const zi={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:i,offsetParent:l,strategy:a}=e;const s="fixed"===a,o=Yt(l),r=!!t&&ri(t.floating);if(l===o||r&&s)return i;let n={scrollLeft:0,scrollTop:0},c=Ct(1);const d=Ct(0),h=ei(l);if((h||!h&&!s)&&(("body"!==Kt(l)||li(o))&&(n=wi(l)),ei(l))){const e=Vi(l);c=Ci(l),d.x=e.x+l.clientLeft,d.y=e.y+l.clientTop}const v=!o||h||s?Ct(0):Ai(o,n);return{width:i.width*c.x,height:i.height*c.y,x:i.x*c.x-n.scrollLeft*c.x+d.x+v.x,y:i.y*c.y-n.scrollTop*c.y+d.y+v.y}},getDocumentElement:Yt,getClippingRect:function(e){let{element:t,boundary:i,rootBoundary:l,strategy:a}=e;const s=[..."clippingAncestors"===i?ri(t)?[]:function(e,t){const i=t.get(e);if(i)return i;let l=bi(e,[],!1).filter(e=>Qt(e)&&"body"!==Kt(e)),a=null;const s="fixed"===ui(e).position;let o=s?fi(e):e;for(;Qt(o)&&!gi(o);){const t=ui(o),i=hi(o);i||"fixed"!==t.position||(a=null),(s?!i&&!a:!i&&"static"===t.position&&a&&$i.has(a.position)||li(o)&&!i&&ki(e,o))?l=l.filter(e=>e!==o):a=t,o=fi(o)}return t.set(e,l),l}(t,this._c):[].concat(i),l],o=s[0],r=s.reduce((e,i)=>{const l=Bi(t,i,a);return e.top=xt(l.top,e.top),e.right=bt(l.right,e.right),e.bottom=bt(l.bottom,e.bottom),e.left=xt(l.left,e.left),e},Bi(t,o,a));return{width:r.right-r.left,height:r.bottom-r.top,x:r.left,y:r.top}},getOffsetParent:Pi,getElementRects:async function(e){const t=this.getOffsetParent||Pi,i=this.getDimensions,l=await i(e.floating);return{reference:Li(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:i}=Zi(e);return{width:t,height:i}},getScale:Ci,isElement:Qt,isRTL:function(e){return"rtl"===ui(e).direction}};function Oi(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ti(e,t,i,l){void 0===l&&(l={});const{ancestorScroll:a=!0,ancestorResize:s=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:r="function"==typeof IntersectionObserver,animationFrame:n=!1}=l,c=yi(e),d=a||s?[...c?bi(c):[],...bi(t)]:[];d.forEach(e=>{a&&e.addEventListener("scroll",i,{passive:!0}),s&&e.addEventListener("resize",i)});const h=c&&r?function(e,t){let i,l=null;const a=Yt(e);function s(){var e;clearTimeout(i),null==(e=l)||e.disconnect(),l=null}return function o(r,n){void 0===r&&(r=!1),void 0===n&&(n=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:v,height:p}=c;if(r||t(),!v||!p)return;const g={rootMargin:-yt(h)+"px "+-yt(a.clientWidth-(d+v))+"px "+-yt(a.clientHeight-(h+p))+"px "+-yt(d)+"px",threshold:xt(0,bt(1,n))||1};let u=!0;function w(t){const l=t[0].intersectionRatio;if(l!==n){if(!u)return o();l?o(!1,l):i=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==l||Oi(c,e.getBoundingClientRect())||o(),u=!1}try{l=new IntersectionObserver(w,{...g,root:a.ownerDocument})}catch(e){l=new IntersectionObserver(w,g)}l.observe(e)}(!0),s}(c,i):null;let v,p=-1,g=null;o&&(g=new ResizeObserver(e=>{let[l]=e;l&&l.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=g)||e.observe(t)})),i()}),c&&!n&&g.observe(c),g.observe(t));let u=n?Vi(e):null;return n&&function t(){const l=Vi(e);u&&!Oi(u,l)&&i();u=l,v=requestAnimationFrame(t)}(),i(),()=>{var e;d.forEach(e=>{a&&e.removeEventListener("scroll",i),s&&e.removeEventListener("resize",i)}),null==h||h(),null==(e=g)||e.disconnect(),g=null,n&&cancelAnimationFrame(v)}}const Ri=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var i,l;const{x:a,y:s,placement:o,middlewareData:r}=t,n=await async function(e,t){const{placement:i,platform:l,elements:a}=e,s=await(null==l.isRTL?void 0:l.isRTL(a.floating)),o=At(i),r=$t(i),n="y"===St(i),c=Ft.has(o)?-1:1,d=s&&n?-1:1,h=Ht(t,e);let{mainAxis:v,crossAxis:p,alignmentAxis:g}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return r&&"number"==typeof g&&(p="end"===r?-1*g:g),n?{x:p*d,y:v*c}:{x:v*c,y:p*d}}(t,e);return o===(null==(i=r.offset)?void 0:i.placement)&&null!=(l=r.arrow)&&l.alignmentOffset?{}:{x:a+n.x,y:s+n.y,data:{...n,placement:o}}}}},Ii=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:i,y:l,placement:a}=t,{mainAxis:s=!0,crossAxis:o=!1,limiter:r={fn:e=>{let{x:t,y:i}=e;return{x:t,y:i}}},...n}=Ht(e,t),c={x:i,y:l},d=await jt(t,n),h=St(At(a)),v=Bt(h);let p=c[v],g=c[h];if(s){const e="y"===v?"bottom":"right";p=Vt(p+d["y"===v?"top":"left"],p,p-d[e])}if(o){const e="y"===h?"bottom":"right";g=Vt(g+d["y"===h?"top":"left"],g,g-d[e])}const u=r.fn({...t,[v]:p,[h]:g});return{...u,data:{x:u.x-i,y:u.y-l,enabled:{[v]:s,[h]:o}}}}}},Di=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var i,l;const{placement:a,middlewareData:s,rects:o,initialPlacement:r,platform:n,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:v,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:u=!0,...w}=Ht(e,t);if(null!=(i=s.arrow)&&i.alignmentOffset)return{};const f=At(a),m=St(r),b=At(r)===r,x=await(null==n.isRTL?void 0:n.isRTL(c.floating)),Z=v||(b||!u?[Nt(r)]:function(e){const t=Nt(e);return[zt(e),t,zt(t)]}(r)),y="none"!==g;!v&&y&&Z.push(...Dt(r,u,g,x));const C=[r,...Z],_=await jt(t,w),M=[];let V=(null==(l=s.flip)?void 0:l.overflows)||[];if(d&&M.push(_[f]),h){const e=Pt(a,o,x);M.push(_[e[0]],_[e[1]])}if(V=[...V,{placement:a,overflows:M}],!M.every(e=>e<=0)){var H,A;const e=((null==(H=s.flip)?void 0:H.index)||0)+1,t=C[e];if(t){if(!("alignment"===h&&m!==St(t))||V.every(e=>St(e.placement)!==m||e.overflows[0]>0))return{data:{index:e,overflows:V},reset:{placement:t}}}let i=null==(A=V.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:A.placement;if(!i)switch(p){case"bestFit":{var $;const e=null==($=V.filter(e=>{if(y){const t=St(e.placement);return t===m||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:$[0];e&&(i=e);break}case"initialPlacement":i=r}if(a!==i)return{reset:{placement:i}}}return{}}}},Ni=(e,t,i)=>{const l=new Map,a={platform:zi,...i},s={...a.platform,_c:l};return(async(e,t,i)=>{const{placement:l="bottom",strategy:a="absolute",middleware:s=[],platform:o}=i,r=s.filter(Boolean),n=await(null==o.isRTL?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:h}=qt(c,l,n),v=l,p={},g=0;for(let i=0;i<r.length;i++){const{name:s,fn:u}=r[i],{x:w,y:f,data:m,reset:b}=await u({x:d,y:h,initialPlacement:l,placement:v,strategy:a,middlewareData:p,rects:c,platform:o,elements:{reference:e,floating:t}});d=null!=w?w:d,h=null!=f?f:h,p={...p,[s]:{...p[s],...m}},b&&g<=50&&(g++,"object"==typeof b&&(b.placement&&(v=b.placement),b.rects&&(c=!0===b.rects?await o.getElementRects({reference:e,floating:t,strategy:a}):b.rects),({x:d,y:h}=qt(c,v,n))),i=-1)}return{x:d,y:h,placement:v,strategy:a,middlewareData:p}})(e,t,{...a,platform:s})};class Ui extends ze{constructor(){super(...arguments),this.myDropdown=ft(),this.dropdownMenuId=function(e="",t=""){return`id-${Math.random().toString().substring(2,6)}-sgds-${e}-${t}`}("dropdown-menu","div"),this.noFlip=!1,this.menuAlignRight=!1,this.drop="down",this.floatingOpts={},this.menuIsOpen=!1,this.close="default",this.disabled=!1,this.readonly=!1,this.menuRef=ft(),this._handleClickOutOfElement=e=>{this.menuIsOpen&&(e.composedPath().includes(this)||this.hideMenu(!0))}}connectedCallback(){super.connectedCallback(),"inside"!==this.close&&document.addEventListener("click",this._handleClickOutOfElement),this.addEventListener("keydown",this._handleKeyboardMenuEvent)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleClickOutOfElement),this.removeEventListener("keydown",this._handleKeyboardMenuEvent),this._cleanupAutoUpdate&&(this._cleanupAutoUpdate(),this._cleanupAutoUpdate=void 0)}firstUpdated(e){super.firstUpdated(e),this.menuIsOpen&&requestAnimationFrame(async()=>{await this.updateFloatingPosition(),this._startAutoUpdate()})}async showMenu(){this.disabled||this.menuIsOpen||(this.menuIsOpen=!0,this.emit("sgds-show"),await this.updateFloatingPosition(),this.emit("sgds-after-show"),this._startAutoUpdate())}_startAutoUpdate(){this.myDropdown.value&&this.menuRef.value&&(this._cleanupAutoUpdate=Ti(this.myDropdown.value,this.menuRef.value,()=>this.updateFloatingPosition()))}hideMenu(e){this.menuIsOpen&&(this.emit("sgds-hide",{detail:{isOutside:e}}),this.menuIsOpen=!1,setTimeout(()=>this.emit("sgds-after-hide"),0),this._cleanupAutoUpdate&&(this._cleanupAutoUpdate(),this._cleanupAutoUpdate=void 0))}toggleMenu(){this.menuIsOpen?this.hideMenu():this.showMenu()}_handleKeyboardMenuEvent(e){if(!this.readonly)switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),this.menuIsOpen||this.showMenu();break;case"Escape":this.hideMenu()}}mergeMiddleware(e,t){const i=e=>{var t;return(null==e?void 0:e.name)||(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)},l=t.map(i),a=e.map(e=>{const a=i(e),s=l.indexOf(a);return-1!==s?t[s]:e}).concat(t.filter(t=>!e.some(e=>i(e)===i(t))));return a}async updateFloatingPosition(){if(!this.myDropdown.value||!this.menuRef.value)return;let e="bottom-start";switch(this.drop){case"up":e=this.menuAlignRight?"top-end":"top-start";break;case"right":e="right-start";break;case"left":e="left-start";break;case"down":e=this.menuAlignRight?"bottom-end":"bottom-start";break;default:e="bottom-start"}const t=[Ri(8),this.noFlip?void 0:Di(),Ii()].filter(Boolean);let i=t;Array.isArray(this.floatingOpts.middleware)&&this.floatingOpts.middleware.length>0&&(i=this.mergeMiddleware(t,this.floatingOpts.middleware.filter(Boolean)));const l=Object.assign(Object.assign({strategy:"fixed",placement:e},this.floatingOpts),{middleware:i}),{x:a,y:s,strategy:o,placement:r}=await Ni(this.myDropdown.value,this.menuRef.value,l);this.menuRef.value.setAttribute("data-placement",r),Object.assign(this.menuRef.value.style,{position:o,left:`${a}px`,top:`${s}px`})}}e([Ve({type:Boolean,state:!0})],Ui.prototype,"noFlip",void 0),e([Ve({type:Boolean,reflect:!0,state:!0})],Ui.prototype,"menuAlignRight",void 0),e([Ve({type:String,reflect:!0,state:!0})],Ui.prototype,"drop",void 0),e([Ve({type:Object})],Ui.prototype,"floatingOpts",void 0),e([Ve({type:Boolean,reflect:!0})],Ui.prototype,"menuIsOpen",void 0),e([Ve({type:Boolean,reflect:!0})],Ui.prototype,"disabled",void 0),e([Ve({type:Boolean,reflect:!0})],Ui.prototype,"readonly",void 0);class Wi extends ze{constructor(){super(...arguments),this.title="",this.name="",this._sidebarCollapsed=!1,this._sidebarActiveItem=null,this._sidebarActiveGroup=null,this._drawerItems=null,this._showDrawer=!1,this._isOverlay=!1,this._childLevel=1,this._selected=!1,this._hidden=!1,this._childElements=[],this._childActive=!1}connectedCallback(){super.connectedCallback(),this._getChildLevel(),this.addEventListener("keydown",this._handleKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this._handleKeyDown)}firstUpdated(e){super.firstUpdated(e),this._getChildLevel()}updated(){2===this._childLevel&&(this._hidden=!this.closest(".sidebar-nested-overlay"))}_handleSlotChange(){this._childElements=this._defaultNodes}_handleClick(){this.emit("i-sgds-click",{detail:{element:this,level:this._childLevel}})}_handleKeyDown(e){var t,i,l,a;const s=e.target;switch(e.key){case" ":case"Enter":return e.preventDefault(),e.stopPropagation(),void(e.target===this&&this._handleClick());case"ArrowDown":{e.preventDefault(),e.stopPropagation();const i=s._childElements[0],l=((null==i?void 0:i._hidden)?null:i)||s.nextElementSibling||(null===(t=s.parentElement)||void 0===t?void 0:t.nextElementSibling);if(null==l?void 0:l.shadowRoot){const e=l.shadowRoot.querySelector("[tabindex]");null==e||e.focus()}return}case"ArrowUp":{e.preventDefault(),e.stopPropagation();const t=null===(i=s.previousElementSibling)||void 0===i?void 0:i._childElements,l=t?t[(null==t?void 0:t.length)-1]:null,a=((null==l?void 0:l._hidden)?null:l)||s.previousElementSibling||s.parentElement;if(null==a?void 0:a.shadowRoot){const e=a.shadowRoot.querySelector("[tabindex]");null==e||e.focus()}return}case"ArrowLeft":if(e.preventDefault(),e.stopPropagation(),this._sidebarActiveGroup===this)this._showDrawer&&this._handleClick();else{if(s._childLevel>=2&&(null===(l=this._sidebarActiveGroup)||void 0===l?void 0:l.shadowRoot)){const e=this._sidebarActiveGroup.shadowRoot.querySelector("[tabindex]");null==e||e.focus()}}return;case"ArrowRight":if(e.preventDefault(),e.stopPropagation(),this._sidebarActiveGroup===this){if(null===(a=this._drawerItems)||void 0===a?void 0:a.length)if(this._showDrawer){const e=this._drawerItems[0];if(null==e?void 0:e.shadowRoot){const t=e.shadowRoot.querySelector("[tabindex]");null==t||t.focus()}}else this._handleClick()}else 1===this._childLevel&&this._childElements.length>0&&this._handleClick();return}}_getChildLevel(){let e=this.parentElement,t=1;for(;"sgds-sidebar-group"===(null==e?void 0:e.tagName.toLowerCase());)t+=1,e=e.parentElement;const i=null==e?void 0:e.classList.contains("sidebar-nested-overlay");this._childLevel=i?t+1:t}}Wi.styles=Ui.styles,e([Ve({type:String,reflect:!0})],Wi.prototype,"title",void 0),e([Ve({type:String,reflect:!0})],Wi.prototype,"name",void 0),e([We({context:Fe,subscribe:!0}),He()],Wi.prototype,"_sidebarCollapsed",void 0),e([We({context:je,subscribe:!0}),He()],Wi.prototype,"_sidebarActiveItem",void 0),e([We({context:qe,subscribe:!0}),He()],Wi.prototype,"_sidebarActiveGroup",void 0),e([We({context:Ge,subscribe:!0}),He()],Wi.prototype,"_drawerItems",void 0),e([We({context:Ke,subscribe:!0}),He()],Wi.prototype,"_showDrawer",void 0),e([We({context:Je,subscribe:!0}),He()],Wi.prototype,"_isOverlay",void 0),e([He()],Wi.prototype,"_childLevel",void 0),e([He()],Wi.prototype,"_selected",void 0),e([He()],Wi.prototype,"_hidden",void 0),e([He()],Wi.prototype,"_childElements",void 0),e([He()],Wi.prototype,"_childActive",void 0),e([Be({flatten:!0})],Wi.prototype,"_defaultNodes",void 0);class qi extends Wi{constructor(){super(...arguments),this._showMenu=!1}get showMenu(){return this._showMenu}_handleActiveItemContext(){this._childLevel>1&&this._sidebarActiveItem&&this.contains(this._sidebarActiveItem)&&(this._showMenu=!0)}_handleClick(){1!==this._childLevel?(this._showMenu=!this._showMenu,this._childElements.forEach(e=>{e._hidden=!this._showMenu})):super._handleClick()}_getIcon(){return 1===this._childLevel?"chevron-right":this._showMenu?"chevron-down":"chevron-up"}render(){return Q`
|
|
2321
2321
|
<div
|
|
2322
|
+
role="button"
|
|
2322
2323
|
class=${Se({"sidebar-item":!0,"sidebar-item--collapsed":!this._isOverlay&&this._sidebarCollapsed&&1===this._childLevel,active:this._selected})}
|
|
2323
2324
|
@click=${()=>this._handleClick()}
|
|
2325
|
+
aria-label=${this.title||this.name}
|
|
2324
2326
|
aria-expanded=${this._showMenu}
|
|
2325
2327
|
tabindex=${this._childLevel>2&&!this._showMenu?-1:0}
|
|
2326
2328
|
>
|
|
@@ -2332,7 +2334,7 @@ const ft=()=>new mt;class mt{}const bt=Math.min,xt=Math.max,Zt=Math.round,yt=Mat
|
|
|
2332
2334
|
|
|
2333
2335
|
<span class="sidebar-item-indicator">
|
|
2334
2336
|
<slot name="indicator"></slot>
|
|
2335
|
-
<sgds-icon
|
|
2337
|
+
<sgds-icon name=${this._getIcon()} size="sm"></sgds-icon>
|
|
2336
2338
|
</span>
|
|
2337
2339
|
</div>
|
|
2338
2340
|
</div>
|