@leafygreen-ui/popover
Advanced tools
Comparing version 11.0.9 to 11.0.10-next.0
# @leafygreen-ui/popover | ||
## 11.0.10-next.0 | ||
### Patch Changes | ||
- b060d06ce: Updates story files for Storybook 7.x | ||
- Updated dependencies [b060d06ce] | ||
- Updated dependencies [b060d06ce] | ||
- @leafygreen-ui/hooks@7.7.4-next.0 | ||
- @leafygreen-ui/leafygreen-provider@3.1.3-next.0 | ||
- @leafygreen-ui/lib@10.3.4-next.0 | ||
- @leafygreen-ui/portal@4.1.3-next.0 | ||
## 11.0.9 | ||
@@ -4,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
import t,{useState as e,useMemo as n,Fragment as o}from"react";import{Transition as r}from"react-transition-group";import i from"prop-types";import{css as a,cx as c}from"@leafygreen-ui/emotion";import{useViewportSize as l,useMutationObserver as s,useObjectDependency as u,usePrevious as f,useIsomorphicLayoutEffect as p}from"@leafygreen-ui/hooks";import{usePopoverContext as d,usePopoverPortalContainer as h}from"@leafygreen-ui/leafygreen-provider";import{consoleOnce as g}from"@leafygreen-ui/lib";import m from"@leafygreen-ui/portal";import{transitionDuration as w}from"@leafygreen-ui/tokens";function y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function v(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),!0).forEach((function(e){E(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function E(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b(){return b=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},b.apply(this,arguments)}function P(t,e){if(null==t)return{};var n,o,r=function(t,e){if(null==t)return{};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function j(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function O(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var o,r,i=[],a=!0,c=!1;try{for(n=n.call(t);!(a=(o=n.next()).done)&&(i.push(o.value),!e||i.length!==e);a=!0);}catch(t){c=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(c)throw r}}return i}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(t){return function(t){if(Array.isArray(t))return x(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){if(t){if("string"==typeof t)return x(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(t,e):void 0}}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}var D,H,R,V,T,F,M,B,L={Top:"top",Bottom:"bottom",Left:"left",Right:"right",CenterVertical:"center-vertical",CenterHorizontal:"center-horizontal"},z={Start:"start",Middle:"middle",End:"end",Fit:"fit"};function N(t){var e=t.useRelativePositioning,n=t.spacing,o=t.align,r=t.justify,i=t.referenceElViewportPos,a=void 0===i?W:i,c=t.referenceElDocumentPos,l=void 0===c?W:c,s=t.contentElViewportPos,u=void 0===s?W:s,f=t.contentElDocumentPos,p=void 0===f?W:f,d=t.scrollContainer,h=t.windowHeight,g=void 0===h?window.innerHeight:h,m=t.windowWidth,w=void 0===m?window.innerWidth:m,y=d?d.offsetWidth:w,E=d?d.offsetHeight:g,b={windowWidth:y,windowHeight:E,referenceElViewportPos:a,contentElViewportPos:u,spacing:n},P=function(t,e){var n=e.spacing,o=e.windowWidth,r=e.windowHeight,i=e.contentElViewportPos,a=e.referenceElViewportPos;return[t].concat(C(et[t])).find((function(t){return[L.Top,L.Bottom,L.CenterVertical].includes(t)?tt({top:K({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowHeight:r,contentHeight:i.height}):!![L.Left,L.Right,L.CenterHorizontal].includes(t)&&_({left:Q({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowWidth:o,contentWidth:i.width})}))||t}(o,b),j=function(t,e,n){var o,r,i=n.spacing,a=n.windowWidth,c=n.windowHeight,l=n.contentElViewportPos,s=n.referenceElViewportPos,u=[t].concat(C(nt[t]));switch(e){case L.Top:case L.Bottom:case L.CenterVertical:return null!==(o=u.find((function(t){return _({contentWidth:t===z.Fit?s.width:l.width,windowWidth:a,left:Q({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==o?o:nt[t][0];case L.Left:case L.Right:case L.CenterHorizontal:return null!==(r=u.find((function(t){return tt({contentHeight:t===z.Fit?s.height:l.height,windowHeight:c,top:K({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==r?r:nt[t][0]}}(r,P,b),O=function(t){var e,n,o=t.align,r=t.justify,i=X[o],a=null!==(e=i.x)&&void 0!==e?e:U[r],c=null!==(n=i.y)&&void 0!==n?n:Z[r];return"".concat(a," ").concat(c)}({align:P,justify:j}),S=function(t,e){var n=.8;switch(t){case L.Top:return"translate3d(0, ".concat(e,"px, 0) scale(").concat(n,")");case L.Bottom:return"translate3d(0, -".concat(e,"px, 0) scale(").concat(n,")");case L.Left:return"translate3d(".concat(e,"px, 0, 0) scale(").concat(n,")");case L.Right:return"translate3d(-".concat(e,"px, 0, 0) scale(").concat(n,")");case L.CenterHorizontal:case L.CenterVertical:return"scale(".concat(n,")")}}(P,n);return 0===Math.floor(u.width)&&r!==z.Fit?{align:o,justify:r,positionCSS:{left:0,top:0,transform:S,transformOrigin:O}}:e?{align:P,justify:j,positionCSS:v(v({},G({align:P,justify:j,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n})),{},{transformOrigin:O,transform:S})}:{align:P,justify:j,positionCSS:v(v({},J({align:P,justify:j,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n,windowHeight:E,windowWidth:y})),{},{transformOrigin:O,transform:S})}}var W={top:0,bottom:0,left:0,right:0,height:0,width:0},A=function(t,e){var n=t.getBoundingClientRect(),o=n.top,r=n.bottom,i=n.left,a=n.right,c=n.width;return{top:o,bottom:r,left:i,right:a,height:t.offsetHeight,width:e?c:parseFloat(getComputedStyle(t).width)}};function I(t,e,n){if(!t)return W;var o=A(t,n),r=o.top,i=o.bottom,a=o.left,c=o.right,l=o.height,s=o.width;if(e){var u=e.scrollTop,f=e.scrollLeft,p=e.getBoundingClientRect();return{top:r+u-p.top,bottom:i+u-p.bottom,left:a+f-p.left,right:c+f-p.right,height:l,width:s}}var d=window,h=d.scrollX,g=d.scrollY;return{top:r+g,bottom:i+g,left:a+h,right:c+h,height:l,width:s}}function k(t,e,n){if(!t)return W;var o=A(t,n),r=o.top,i=o.bottom,a=o.left,c=o.right,l=o.height,s=o.width;if(e){var u=e.getBoundingClientRect();return{top:r-u.top,bottom:i-u.bottom,left:a-u.left,right:c-u.right,height:l,width:s}}return{top:r,bottom:i,left:a,right:c,height:l,width:s}}var Z=(E(D={},z.Start,"top"),E(D,z.Middle,"center"),E(D,z.End,"bottom"),E(D,z.Fit,"center"),D),U=(E(H={},z.Start,"left"),E(H,z.Middle,"center"),E(H,z.End,"right"),E(H,z.Fit,"center"),H),X=(E(R={},L.Left,{x:"right"}),E(R,L.Right,{x:"left"}),E(R,L.Top,{y:"bottom"}),E(R,L.Bottom,{y:"top"}),E(R,L.CenterHorizontal,{x:"center"}),E(R,L.CenterVertical,{y:"center"}),R);var Y=(E(V={},z.Start,{top:0}),E(V,z.End,{bottom:0}),E(V,z.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{top:"".concat(n.height/2-e.height/2,"px")}})),E(V,z.Fit,{top:0,bottom:0}),V),$=(E(T={},z.Start,{left:0}),E(T,z.End,{right:0}),E(T,z.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{left:"".concat(n.width/2-e.width/2,"px")}})),E(T,z.Fit,{left:0,right:0}),T),q=(E(F={},L.Top,{constant:function(t){var e=t.spacing;return{bottom:"calc(100% + ".concat(e,"px)")}},justifyPositions:$}),E(F,L.Bottom,{constant:function(t){var e=t.spacing;return{top:"calc(100% + ".concat(e,"px)")}},justifyPositions:$}),E(F,L.CenterVertical,{constant:function(t){var e=t.referenceElDocumentPos;return{top:"calc(".concat(e.height/2,"px - 50%)")}},justifyPositions:$}),E(F,L.Left,{constant:function(t){var e=t.spacing;return{right:"calc(100% + ".concat(e,"px)")}},justifyPositions:Y}),E(F,L.Right,{constant:function(t){var e=t.spacing;return{left:"calc(100% + ".concat(e,"px)")}},justifyPositions:Y}),E(F,L.CenterHorizontal,{constant:function(t){var e=t.referenceElDocumentPos;return{left:"calc(".concat(e.width/2,"px - 50%)")}},justifyPositions:Y}),F);function G(t){var e,n=t.align,o=t.justify,r=t.referenceElDocumentPos,i=t.contentElDocumentPos,a=t.spacing,c=q[n],l=c.justifyPositions[o],s={contentElDocumentPos:i,referenceElDocumentPos:r,spacing:a};return v(v({},null===(e=c.constant)||void 0===e?void 0:e.call(c,s)),"function"==typeof l?l(s):l)}function J(t){var e=t.align,n=t.justify,o=t.referenceElDocumentPos,r=t.contentElDocumentPos,i=t.spacing,a=t.windowWidth,c=t.windowHeight,l=Q({align:e,justify:n,referenceElPos:o,contentElPos:r,spacing:i}),s="".concat(l,"px"),u="".concat(K({align:e,justify:n,referenceElPos:o,contentElPos:r,spacing:i}),"px");return n!==z.Fit?{left:s,top:u}:[L.Left,L.Right,L.CenterHorizontal].includes(e)?{left:s,top:u,bottom:"".concat(c-o.bottom,"px")}:{left:s,top:u,right:"".concat(a-(l+o.width),"px")}}function K(t){var e=t.align,n=t.justify,o=t.contentElPos,r=t.referenceElPos,i=t.spacing;switch(e){case L.Left:case L.Right:case L.CenterHorizontal:switch(n){case z.Start:case z.Fit:return r.top;case z.End:return r.top+r.height-o.height;default:return r.top-(o.height-r.height)/2}case L.CenterVertical:return r.top-(o.height-r.height)/2;case L.Top:return r.top-o.height-i;case L.Bottom:default:return r.top+r.height+i}}function Q(t){var e=t.align,n=t.justify,o=t.contentElPos,r=t.referenceElPos,i=t.spacing;switch(e){case L.Top:case L.Bottom:case L.CenterVertical:switch(n){case z.End:return r.left+r.width-o.width;case z.Middle:return r.left-(o.width-r.width)/2;default:return r.left}case L.Left:return r.left-o.width-i;case L.Right:return r.left+r.width+i;case L.CenterHorizontal:default:return r.left-(o.width-r.width)/2}}function _(t){var e=t.left,n=t.windowWidth,o=t.contentWidth;return e>=0&&!(e+o>n)}function tt(t){var e=t.top,n=t.windowHeight,o=t.contentHeight;return e>=0&&!(e+o>n)}var et=(E(M={},L.Top,[L.Bottom]),E(M,L.Bottom,[L.Top]),E(M,L.Left,[L.Right]),E(M,L.Right,[L.Left]),E(M,L.CenterHorizontal,[L.Left,L.Right]),E(M,L.CenterVertical,[L.Top,L.Bottom]),M);var nt=(E(B={},z.Start,[z.End,z.Middle]),E(B,z.Middle,[z.End,z.Start]),E(B,z.End,[z.Start,z.Middle]),E(B,z.Fit,[z.Middle,z.Start,z.End]),B);var ot,rt,it,at,ct,lt=["active","spacing","align","justify","adjustOnMutation","children","className","popoverZIndex","refEl","usePortal","portalClassName","portalContainer","scrollContainer"],st=["transform"],ut=a(ot||(ot=j(["\n position: absolute;\n transition: transform ","ms ease-in-out,\n opacity ","ms ease-in-out;\n opacity: 0;\n"])),w.default,w.default),ft={attributes:!0,characterData:!0,childList:!0,subtree:!0};function pt(i){var w=i.active,y=void 0!==w&&w,v=i.spacing,C=void 0===v?10:v,S=i.align,x=void 0===S?L.Bottom:S,D=i.justify,H=void 0===D?z.Start:D,R=i.adjustOnMutation,V=void 0!==R&&R,T=i.children,F=i.className,M=i.popoverZIndex,B=i.refEl,W=i.usePortal,A=void 0===W||W,Z=i.portalClassName,U=i.portalContainer,X=i.scrollContainer,Y=P(i,lt),$=O(e(null),2),q=$[0],G=$[1],J=O(e(null),2),K=J[0],Q=J[1],_=O(e(0),2),tt=_[0],et=_[1],nt=d().setIsPopoverOpen,ot=h(),pt=ot.portalContainer,dt=ot.scrollContainer;pt=U||pt,dt=X||dt,A&&dt&&(dt.contains(pt)||g.warn("To ensure correct positioning make sure that the portalContainer element is inside of the scrollContainer"));var ht=t.useRef(K);ht.current=K;var gt=null;if(B&&B.current)gt=B.current;else if(q){var mt=q.parentNode;mt&&mt instanceof HTMLElement&&(gt=mt)}var wt=l(),yt=V&&y,vt=s(gt,ft,Date.now,yt),Et=s(null==K?void 0:K.parentNode,ft,Date.now,yt),bt=u(k(gt,dt,!0)),Pt=u(k(null==K?void 0:K.parentNode,dt)),jt=u(n((function(){return I(gt,dt,!0)}),[gt,dt,wt,vt,y,x,H,tt])),Ot=u(n((function(){return I(K)}),[null==K?void 0:K.parentNode,wt,Et,y,x,H,tt])),Ct=f(H),St=f(x),xt=Ct!==H&&(H===z.Fit||Ct===z.Fit)||St!==x&&H===z.Fit;p((function(){xt&&et((function(t){return t+1}))}),[xt]);var Dt=O(e(!1),2),Ht=Dt[0],Rt=Dt[1];if(p((function(){return Rt(!0)}),[]),!Ht)return null;var Vt,Tt=N({useRelativePositioning:!A,spacing:C,align:x,justify:H,referenceElViewportPos:bt,referenceElDocumentPos:jt,contentElViewportPos:Pt,contentElDocumentPos:Ot,scrollContainer:dt}),Ft=Tt.align,Mt=Tt.justify,Bt=Tt.positionCSS,Lt=Bt.transform,zt=P(Bt,st),Nt=a(rt||(rt=j(["\n opacity: 1;\n position: ",";\n pointer-events: initial;\n "])),A?"":"absolute"),Wt=A?m:o,At=A?pt?{container:pt}:{className:null!=Z?Z:void 0}:{};return Vt=null==T?null:"function"==typeof T?T({align:Ft,justify:Mt,referenceElPos:jt}):T,t.createElement(r,{nodeRef:ht,in:y,timeout:150,mountOnEnter:!0,unmountOnExit:!0,appear:!0,onEntered:function(){return nt(!0)},onExit:function(){return nt(!1)}},(function(e){var n;return t.createElement(t.Fragment,null,t.createElement("span",{ref:G,className:a(it||(it=j(["\n display: none;\n "])))}),t.createElement(Wt,At,t.createElement("div",b({},Y,{className:c(ut,a(zt),(n={},E(n,a({transform:Lt}),"entering"===e||"exiting"===e),E(n,Nt,"entered"===e),E(n,a(at||(at=j(["\n z-index: ",";\n "])),M),"number"==typeof M),n),F,E({},a(ct||(ct=j(["\n transition-delay: 0ms;\n "]))),"exiting"===e))}),t.createElement("div",{ref:Q},Vt))))}))}pt.displayName="Popover",pt.propTypes={children:i.oneOfType([i.node,i.func]),active:i.bool,className:i.string,align:i.oneOf(Object.values(L)),justify:i.oneOf(Object.values(z)),refEl:i.shape({current:"undefined"!=typeof window?i.instanceOf(Element):i.any}),usePortal:i.bool,portalClassName:i.string,spacing:i.number,adjustOnMutation:i.bool};export{L as Align,z as Justify,pt as default}; | ||
import t,{useState as e,useMemo as n,Fragment as r}from"react";import{Transition as o}from"react-transition-group";import i from"prop-types";import{css as a,cx as c}from"@leafygreen-ui/emotion";import{useViewportSize as l,useMutationObserver as s,useObjectDependency as u,usePrevious as f,useIsomorphicLayoutEffect as p}from"@leafygreen-ui/hooks";import{usePopoverContext as d,usePopoverPortalContainer as h}from"@leafygreen-ui/leafygreen-provider";import{consoleOnce as g}from"@leafygreen-ui/lib";import m from"@leafygreen-ui/portal";import{transitionDuration as y}from"@leafygreen-ui/tokens";function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function w(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?v(Object(n),!0).forEach((function(e){b(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function b(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function E(){return E=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},E.apply(this,arguments)}function P(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function j(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function O(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,c=[],l=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(c.push(r.value),c.length!==e);l=!0);}catch(t){s=!0,o=t}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(t){return function(t){if(Array.isArray(t))return x(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){if(t){if("string"==typeof t)return x(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(t,e):void 0}}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var D,H,R,T,V,F,M,B,L={Top:"top",Bottom:"bottom",Left:"left",Right:"right",CenterVertical:"center-vertical",CenterHorizontal:"center-horizontal"},N={Start:"start",Middle:"middle",End:"end",Fit:"fit"};function z(t){var e=t.useRelativePositioning,n=t.spacing,r=t.align,o=t.justify,i=t.referenceElViewportPos,a=void 0===i?W:i,c=t.referenceElDocumentPos,l=void 0===c?W:c,s=t.contentElViewportPos,u=void 0===s?W:s,f=t.contentElDocumentPos,p=void 0===f?W:f,d=t.scrollContainer,h=t.windowHeight,g=void 0===h?window.innerHeight:h,m=t.windowWidth,y=void 0===m?window.innerWidth:m,v=d?d.offsetWidth:y,b=d?d.offsetHeight:g,E={windowWidth:v,windowHeight:b,referenceElViewportPos:a,contentElViewportPos:u,spacing:n},P=function(t,e){var n=e.spacing,r=e.windowWidth,o=e.windowHeight,i=e.contentElViewportPos,a=e.referenceElViewportPos;return[t].concat(C(et[t])).find((function(t){return[L.Top,L.Bottom,L.CenterVertical].includes(t)?tt({top:K({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowHeight:o,contentHeight:i.height}):!![L.Left,L.Right,L.CenterHorizontal].includes(t)&&_({left:Q({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowWidth:r,contentWidth:i.width})}))||t}(r,E),j=function(t,e,n){var r,o,i=n.spacing,a=n.windowWidth,c=n.windowHeight,l=n.contentElViewportPos,s=n.referenceElViewportPos,u=[t].concat(C(nt[t]));switch(e){case L.Top:case L.Bottom:case L.CenterVertical:return null!==(r=u.find((function(t){return _({contentWidth:t===N.Fit?s.width:l.width,windowWidth:a,left:Q({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==r?r:nt[t][0];case L.Left:case L.Right:case L.CenterHorizontal:return null!==(o=u.find((function(t){return tt({contentHeight:t===N.Fit?s.height:l.height,windowHeight:c,top:K({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==o?o:nt[t][0]}}(o,P,E),O=function(t){var e,n,r=t.align,o=t.justify,i=X[r],a=null!==(e=i.x)&&void 0!==e?e:U[o],c=null!==(n=i.y)&&void 0!==n?n:Z[o];return"".concat(a," ").concat(c)}({align:P,justify:j}),S=function(t,e){var n=.8;switch(t){case L.Top:return"translate3d(0, ".concat(e,"px, 0) scale(").concat(n,")");case L.Bottom:return"translate3d(0, -".concat(e,"px, 0) scale(").concat(n,")");case L.Left:return"translate3d(".concat(e,"px, 0, 0) scale(").concat(n,")");case L.Right:return"translate3d(-".concat(e,"px, 0, 0) scale(").concat(n,")");case L.CenterHorizontal:case L.CenterVertical:return"scale(".concat(n,")")}}(P,n);return 0===Math.floor(u.width)&&o!==N.Fit?{align:r,justify:o,positionCSS:{left:0,top:0,transform:S,transformOrigin:O}}:e?{align:P,justify:j,positionCSS:w(w({},G({align:P,justify:j,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n})),{},{transformOrigin:O,transform:S})}:{align:P,justify:j,positionCSS:w(w({},J({align:P,justify:j,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n,windowHeight:b,windowWidth:v})),{},{transformOrigin:O,transform:S})}}var W={top:0,bottom:0,left:0,right:0,height:0,width:0},A=function(t,e){var n=t.getBoundingClientRect(),r=n.top,o=n.bottom,i=n.left,a=n.right,c=n.width;return{top:r,bottom:o,left:i,right:a,height:t.offsetHeight,width:e?c:parseFloat(getComputedStyle(t).width)}};function I(t,e,n){if(!t)return W;var r=A(t,n),o=r.top,i=r.bottom,a=r.left,c=r.right,l=r.height,s=r.width;if(e){var u=e.scrollTop,f=e.scrollLeft,p=e.getBoundingClientRect();return{top:o+u-p.top,bottom:i+u-p.bottom,left:a+f-p.left,right:c+f-p.right,height:l,width:s}}var d=window,h=d.scrollX,g=d.scrollY;return{top:o+g,bottom:i+g,left:a+h,right:c+h,height:l,width:s}}function k(t,e,n){if(!t)return W;var r=A(t,n),o=r.top,i=r.bottom,a=r.left,c=r.right,l=r.height,s=r.width;if(e){var u=e.getBoundingClientRect();return{top:o-u.top,bottom:i-u.bottom,left:a-u.left,right:c-u.right,height:l,width:s}}return{top:o,bottom:i,left:a,right:c,height:l,width:s}}var Z=(b(D={},N.Start,"top"),b(D,N.Middle,"center"),b(D,N.End,"bottom"),b(D,N.Fit,"center"),D),U=(b(H={},N.Start,"left"),b(H,N.Middle,"center"),b(H,N.End,"right"),b(H,N.Fit,"center"),H),X=(b(R={},L.Left,{x:"right"}),b(R,L.Right,{x:"left"}),b(R,L.Top,{y:"bottom"}),b(R,L.Bottom,{y:"top"}),b(R,L.CenterHorizontal,{x:"center"}),b(R,L.CenterVertical,{y:"center"}),R);var Y=(b(T={},N.Start,{top:0}),b(T,N.End,{bottom:0}),b(T,N.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{top:"".concat(n.height/2-e.height/2,"px")}})),b(T,N.Fit,{top:0,bottom:0}),T),$=(b(V={},N.Start,{left:0}),b(V,N.End,{right:0}),b(V,N.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{left:"".concat(n.width/2-e.width/2,"px")}})),b(V,N.Fit,{left:0,right:0}),V),q=(b(F={},L.Top,{constant:function(t){var e=t.spacing;return{bottom:"calc(100% + ".concat(e,"px)")}},justifyPositions:$}),b(F,L.Bottom,{constant:function(t){var e=t.spacing;return{top:"calc(100% + ".concat(e,"px)")}},justifyPositions:$}),b(F,L.CenterVertical,{constant:function(t){var e=t.referenceElDocumentPos;return{top:"calc(".concat(e.height/2,"px - 50%)")}},justifyPositions:$}),b(F,L.Left,{constant:function(t){var e=t.spacing;return{right:"calc(100% + ".concat(e,"px)")}},justifyPositions:Y}),b(F,L.Right,{constant:function(t){var e=t.spacing;return{left:"calc(100% + ".concat(e,"px)")}},justifyPositions:Y}),b(F,L.CenterHorizontal,{constant:function(t){var e=t.referenceElDocumentPos;return{left:"calc(".concat(e.width/2,"px - 50%)")}},justifyPositions:Y}),F);function G(t){var e,n=t.align,r=t.justify,o=t.referenceElDocumentPos,i=t.contentElDocumentPos,a=t.spacing,c=q[n],l=c.justifyPositions[r],s={contentElDocumentPos:i,referenceElDocumentPos:o,spacing:a};return w(w({},null===(e=c.constant)||void 0===e?void 0:e.call(c,s)),"function"==typeof l?l(s):l)}function J(t){var e=t.align,n=t.justify,r=t.referenceElDocumentPos,o=t.contentElDocumentPos,i=t.spacing,a=t.windowWidth,c=t.windowHeight,l=Q({align:e,justify:n,referenceElPos:r,contentElPos:o,spacing:i}),s="".concat(l,"px"),u="".concat(K({align:e,justify:n,referenceElPos:r,contentElPos:o,spacing:i}),"px");return n!==N.Fit?{left:s,top:u}:[L.Left,L.Right,L.CenterHorizontal].includes(e)?{left:s,top:u,bottom:"".concat(c-r.bottom,"px")}:{left:s,top:u,right:"".concat(a-(l+r.width),"px")}}function K(t){var e=t.align,n=t.justify,r=t.contentElPos,o=t.referenceElPos,i=t.spacing;switch(e){case L.Left:case L.Right:case L.CenterHorizontal:switch(n){case N.Start:case N.Fit:return o.top;case N.End:return o.top+o.height-r.height;default:return o.top-(r.height-o.height)/2}case L.CenterVertical:return o.top-(r.height-o.height)/2;case L.Top:return o.top-r.height-i;case L.Bottom:default:return o.top+o.height+i}}function Q(t){var e=t.align,n=t.justify,r=t.contentElPos,o=t.referenceElPos,i=t.spacing;switch(e){case L.Top:case L.Bottom:case L.CenterVertical:switch(n){case N.End:return o.left+o.width-r.width;case N.Middle:return o.left-(r.width-o.width)/2;default:return o.left}case L.Left:return o.left-r.width-i;case L.Right:return o.left+o.width+i;case L.CenterHorizontal:default:return o.left-(r.width-o.width)/2}}function _(t){var e=t.left,n=t.windowWidth,r=t.contentWidth;return e>=0&&!(e+r>n)}function tt(t){var e=t.top,n=t.windowHeight,r=t.contentHeight;return e>=0&&!(e+r>n)}var et=(b(M={},L.Top,[L.Bottom]),b(M,L.Bottom,[L.Top]),b(M,L.Left,[L.Right]),b(M,L.Right,[L.Left]),b(M,L.CenterHorizontal,[L.Left,L.Right]),b(M,L.CenterVertical,[L.Top,L.Bottom]),M);var nt=(b(B={},N.Start,[N.End,N.Middle]),b(B,N.Middle,[N.End,N.Start]),b(B,N.End,[N.Start,N.Middle]),b(B,N.Fit,[N.Middle,N.Start,N.End]),B);var rt,ot,it,at,ct,lt=["active","spacing","align","justify","adjustOnMutation","children","className","popoverZIndex","refEl","usePortal","portalClassName","portalContainer","scrollContainer"],st=["transform"],ut=a(rt||(rt=j(["\n position: absolute;\n transition: transform ","ms ease-in-out,\n opacity ","ms ease-in-out;\n opacity: 0;\n"])),y.default,y.default),ft={attributes:!0,characterData:!0,childList:!0,subtree:!0};function pt(i){var y=i.active,v=void 0!==y&&y,w=i.spacing,C=void 0===w?10:w,S=i.align,x=void 0===S?L.Bottom:S,D=i.justify,H=void 0===D?N.Start:D,R=i.adjustOnMutation,T=void 0!==R&&R,V=i.children,F=i.className,M=i.popoverZIndex,B=i.refEl,W=i.usePortal,A=void 0===W||W,Z=i.portalClassName,U=i.portalContainer,X=i.scrollContainer,Y=P(i,lt),$=O(e(null),2),q=$[0],G=$[1],J=O(e(null),2),K=J[0],Q=J[1],_=O(e(0),2),tt=_[0],et=_[1],nt=d().setIsPopoverOpen,rt=h(),pt=rt.portalContainer,dt=rt.scrollContainer;pt=U||pt,dt=X||dt,A&&dt&&(dt.contains(pt)||g.warn("To ensure correct positioning make sure that the portalContainer element is inside of the scrollContainer"));var ht=t.useRef(K);ht.current=K;var gt=null;if(B&&B.current)gt=B.current;else if(q){var mt=q.parentNode;mt&&mt instanceof HTMLElement&&(gt=mt)}var yt=l(),vt=T&&v,wt=s(gt,ft,Date.now,vt),bt=s(null==K?void 0:K.parentNode,ft,Date.now,vt),Et=u(k(gt,dt,!0)),Pt=u(k(null==K?void 0:K.parentNode,dt)),jt=u(n((function(){return I(gt,dt,!0)}),[gt,dt,yt,wt,v,x,H,tt])),Ot=u(n((function(){return I(K)}),[null==K?void 0:K.parentNode,yt,bt,v,x,H,tt])),Ct=f(H),St=f(x),xt=Ct!==H&&(H===N.Fit||Ct===N.Fit)||St!==x&&H===N.Fit;p((function(){xt&&et((function(t){return t+1}))}),[xt]);var Dt=O(e(!1),2),Ht=Dt[0],Rt=Dt[1];if(p((function(){return Rt(!0)}),[]),!Ht)return null;var Tt,Vt=z({useRelativePositioning:!A,spacing:C,align:x,justify:H,referenceElViewportPos:Et,referenceElDocumentPos:jt,contentElViewportPos:Pt,contentElDocumentPos:Ot,scrollContainer:dt}),Ft=Vt.align,Mt=Vt.justify,Bt=Vt.positionCSS,Lt=Bt.transform,Nt=P(Bt,st),zt=a(ot||(ot=j(["\n opacity: 1;\n position: ",";\n pointer-events: initial;\n "])),A?"":"absolute"),Wt=A?m:r,At=A?pt?{container:pt}:{className:null!=Z?Z:void 0}:{};return Tt=null==V?null:"function"==typeof V?V({align:Ft,justify:Mt,referenceElPos:jt}):V,t.createElement(o,{nodeRef:ht,in:v,timeout:150,mountOnEnter:!0,unmountOnExit:!0,appear:!0,onEntered:function(){return nt(!0)},onExit:function(){return nt(!1)}},(function(e){var n;return t.createElement(t.Fragment,null,t.createElement("span",{ref:G,className:a(it||(it=j(["\n display: none;\n "])))}),t.createElement(Wt,At,t.createElement("div",E({},Y,{className:c(ut,a(Nt),(n={},b(n,a({transform:Lt}),"entering"===e||"exiting"===e),b(n,zt,"entered"===e),b(n,a(at||(at=j(["\n z-index: ",";\n "])),M),"number"==typeof M),n),F,b({},a(ct||(ct=j(["\n transition-delay: 0ms;\n "]))),"exiting"===e))}),t.createElement("div",{ref:Q},Tt))))}))}pt.displayName="Popover",pt.propTypes={children:i.oneOfType([i.node,i.func]),active:i.bool,className:i.string,align:i.oneOf(Object.values(L)),justify:i.oneOf(Object.values(N)),refEl:i.shape({current:"undefined"!=typeof window?i.instanceOf(Element):i.any}),usePortal:i.bool,portalClassName:i.string,spacing:i.number,adjustOnMutation:i.bool};export{L as Align,N as Justify,pt as default}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-transition-group"),require("prop-types"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/leafygreen-provider"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/portal"),require("@leafygreen-ui/tokens")):"function"==typeof define&&define.amd?define(["exports","react","react-transition-group","prop-types","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/leafygreen-provider","@leafygreen-ui/lib","@leafygreen-ui/portal","@leafygreen-ui/tokens"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@leafygreen-ui/popover"]={},t.React,t.reactTransitionGroup,t.PropTypes,t["@leafygreen-ui/emotion"],t["@leafygreen-ui/hooks"],t["@leafygreen-ui/leafygreen-provider"],t["@leafygreen-ui/lib"],t["@leafygreen-ui/portal"],t["@leafygreen-ui/tokens"])}(this,(function(t,e,n,r,o,i,a,c,l,u){"use strict";function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var f=s(e),d=s(r),p=s(l);function g(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?g(Object(n),!0).forEach((function(e){y(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function y(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function m(){return m=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},m.apply(this,arguments)}function v(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function w(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function b(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,c=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}(t,e)||E(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t){return function(t){if(Array.isArray(t))return j(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||E(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t,e){if(t){if("string"==typeof t)return j(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?j(t,e):void 0}}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var O,C,S,x,D,H,T,M,R={Top:"top",Bottom:"bottom",Left:"left",Right:"right",CenterVertical:"center-vertical",CenterHorizontal:"center-horizontal"},V={Start:"start",Middle:"middle",End:"end",Fit:"fit"};function F(t){var e=t.useRelativePositioning,n=t.spacing,r=t.align,o=t.justify,i=t.referenceElViewportPos,a=void 0===i?L:i,c=t.referenceElDocumentPos,l=void 0===c?L:c,u=t.contentElViewportPos,s=void 0===u?L:u,f=t.contentElDocumentPos,d=void 0===f?L:f,p=t.scrollContainer,g=t.windowHeight,y=void 0===g?window.innerHeight:g,m=t.windowWidth,v=void 0===m?window.innerWidth:m,w=p?p.offsetWidth:v,b=p?p.offsetHeight:y,E={windowWidth:w,windowHeight:b,referenceElViewportPos:a,contentElViewportPos:s,spacing:n},j=function(t,e){var n=e.spacing,r=e.windowWidth,o=e.windowHeight,i=e.contentElViewportPos,a=e.referenceElViewportPos;return[t].concat(P($[t])).find((function(t){return[R.Top,R.Bottom,R.CenterVertical].includes(t)?Y({top:J({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowHeight:o,contentHeight:i.height}):!![R.Left,R.Right,R.CenterHorizontal].includes(t)&&X({left:U({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowWidth:r,contentWidth:i.width})}))||t}(r,E),O=function(t,e,n){var r,o,i=n.spacing,a=n.windowWidth,c=n.windowHeight,l=n.contentElViewportPos,u=n.referenceElViewportPos,s=[t].concat(P(K[t]));switch(e){case R.Top:case R.Bottom:case R.CenterVertical:return null!==(r=s.find((function(t){return X({contentWidth:t===V.Fit?u.width:l.width,windowWidth:a,left:U({contentElPos:l,referenceElPos:u,spacing:i,align:e,justify:t})})})))&&void 0!==r?r:K[t][0];case R.Left:case R.Right:case R.CenterHorizontal:return null!==(o=s.find((function(t){return Y({contentHeight:t===V.Fit?u.height:l.height,windowHeight:c,top:J({contentElPos:l,referenceElPos:u,spacing:i,align:e,justify:t})})})))&&void 0!==o?o:K[t][0]}}(o,j,E),C=function(t){var e,n,r=t.align,o=t.justify,i=A[r],a=null!==(e=i.x)&&void 0!==e?e:I[o],c=null!==(n=i.y)&&void 0!==n?n:W[o];return"".concat(a," ").concat(c)}({align:j,justify:O}),S=function(t,e){var n=.8;switch(t){case R.Top:return"translate3d(0, ".concat(e,"px, 0) scale(").concat(n,")");case R.Bottom:return"translate3d(0, -".concat(e,"px, 0) scale(").concat(n,")");case R.Left:return"translate3d(".concat(e,"px, 0, 0) scale(").concat(n,")");case R.Right:return"translate3d(-".concat(e,"px, 0, 0) scale(").concat(n,")");case R.CenterHorizontal:case R.CenterVertical:return"scale(".concat(n,")")}}(j,n);return 0===Math.floor(s.width)&&o!==V.Fit?{align:r,justify:o,positionCSS:{left:0,top:0,transform:S,transformOrigin:C}}:e?{align:j,justify:O,positionCSS:h(h({},_({align:j,justify:O,referenceElDocumentPos:l,contentElDocumentPos:d,spacing:n})),{},{transformOrigin:C,transform:S})}:{align:j,justify:O,positionCSS:h(h({},G({align:j,justify:O,referenceElDocumentPos:l,contentElDocumentPos:d,spacing:n,windowHeight:b,windowWidth:w})),{},{transformOrigin:C,transform:S})}}var L={top:0,bottom:0,left:0,right:0,height:0,width:0},z=function(t,e){var n=t.getBoundingClientRect(),r=n.top,o=n.bottom,i=n.left,a=n.right,c=n.width;return{top:r,bottom:o,left:i,right:a,height:t.offsetHeight,width:e?c:parseFloat(getComputedStyle(t).width)}};function B(t,e,n){if(!t)return L;var r=z(t,n),o=r.top,i=r.bottom,a=r.left,c=r.right,l=r.height,u=r.width;if(e){var s=e.scrollTop,f=e.scrollLeft,d=e.getBoundingClientRect();return{top:o+s-d.top,bottom:i+s-d.bottom,left:a+f-d.left,right:c+f-d.right,height:l,width:u}}var p=window,g=p.scrollX,h=p.scrollY;return{top:o+h,bottom:i+h,left:a+g,right:c+g,height:l,width:u}}function N(t,e,n){if(!t)return L;var r=z(t,n),o=r.top,i=r.bottom,a=r.left,c=r.right,l=r.height,u=r.width;if(e){var s=e.getBoundingClientRect();return{top:o-s.top,bottom:i-s.bottom,left:a-s.left,right:c-s.right,height:l,width:u}}return{top:o,bottom:i,left:a,right:c,height:l,width:u}}var W=(y(O={},V.Start,"top"),y(O,V.Middle,"center"),y(O,V.End,"bottom"),y(O,V.Fit,"center"),O),I=(y(C={},V.Start,"left"),y(C,V.Middle,"center"),y(C,V.End,"right"),y(C,V.Fit,"center"),C),A=(y(S={},R.Left,{x:"right"}),y(S,R.Right,{x:"left"}),y(S,R.Top,{y:"bottom"}),y(S,R.Bottom,{y:"top"}),y(S,R.CenterHorizontal,{x:"center"}),y(S,R.CenterVertical,{y:"center"}),S);var k=(y(x={},V.Start,{top:0}),y(x,V.End,{bottom:0}),y(x,V.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{top:"".concat(n.height/2-e.height/2,"px")}})),y(x,V.Fit,{top:0,bottom:0}),x),q=(y(D={},V.Start,{left:0}),y(D,V.End,{right:0}),y(D,V.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{left:"".concat(n.width/2-e.width/2,"px")}})),y(D,V.Fit,{left:0,right:0}),D),Z=(y(H={},R.Top,{constant:function(t){var e=t.spacing;return{bottom:"calc(100% + ".concat(e,"px)")}},justifyPositions:q}),y(H,R.Bottom,{constant:function(t){var e=t.spacing;return{top:"calc(100% + ".concat(e,"px)")}},justifyPositions:q}),y(H,R.CenterVertical,{constant:function(t){var e=t.referenceElDocumentPos;return{top:"calc(".concat(e.height/2,"px - 50%)")}},justifyPositions:q}),y(H,R.Left,{constant:function(t){var e=t.spacing;return{right:"calc(100% + ".concat(e,"px)")}},justifyPositions:k}),y(H,R.Right,{constant:function(t){var e=t.spacing;return{left:"calc(100% + ".concat(e,"px)")}},justifyPositions:k}),y(H,R.CenterHorizontal,{constant:function(t){var e=t.referenceElDocumentPos;return{left:"calc(".concat(e.width/2,"px - 50%)")}},justifyPositions:k}),H);function _(t){var e,n=t.align,r=t.justify,o=t.referenceElDocumentPos,i=t.contentElDocumentPos,a=t.spacing,c=Z[n],l=c.justifyPositions[r],u={contentElDocumentPos:i,referenceElDocumentPos:o,spacing:a};return h(h({},null===(e=c.constant)||void 0===e?void 0:e.call(c,u)),"function"==typeof l?l(u):l)}function G(t){var e=t.align,n=t.justify,r=t.referenceElDocumentPos,o=t.contentElDocumentPos,i=t.spacing,a=t.windowWidth,c=t.windowHeight,l=U({align:e,justify:n,referenceElPos:r,contentElPos:o,spacing:i}),u="".concat(l,"px"),s="".concat(J({align:e,justify:n,referenceElPos:r,contentElPos:o,spacing:i}),"px");return n!==V.Fit?{left:u,top:s}:[R.Left,R.Right,R.CenterHorizontal].includes(e)?{left:u,top:s,bottom:"".concat(c-r.bottom,"px")}:{left:u,top:s,right:"".concat(a-(l+r.width),"px")}}function J(t){var e=t.align,n=t.justify,r=t.contentElPos,o=t.referenceElPos,i=t.spacing;switch(e){case R.Left:case R.Right:case R.CenterHorizontal:switch(n){case V.Start:case V.Fit:return o.top;case V.End:return o.top+o.height-r.height;default:return o.top-(r.height-o.height)/2}case R.CenterVertical:return o.top-(r.height-o.height)/2;case R.Top:return o.top-r.height-i;case R.Bottom:default:return o.top+o.height+i}}function U(t){var e=t.align,n=t.justify,r=t.contentElPos,o=t.referenceElPos,i=t.spacing;switch(e){case R.Top:case R.Bottom:case R.CenterVertical:switch(n){case V.End:return o.left+o.width-r.width;case V.Middle:return o.left-(r.width-o.width)/2;default:return o.left}case R.Left:return o.left-r.width-i;case R.Right:return o.left+o.width+i;case R.CenterHorizontal:default:return o.left-(r.width-o.width)/2}}function X(t){var e=t.left,n=t.windowWidth,r=t.contentWidth;return e>=0&&!(e+r>n)}function Y(t){var e=t.top,n=t.windowHeight,r=t.contentHeight;return e>=0&&!(e+r>n)}var $=(y(T={},R.Top,[R.Bottom]),y(T,R.Bottom,[R.Top]),y(T,R.Left,[R.Right]),y(T,R.Right,[R.Left]),y(T,R.CenterHorizontal,[R.Left,R.Right]),y(T,R.CenterVertical,[R.Top,R.Bottom]),T);var K=(y(M={},V.Start,[V.End,V.Middle]),y(M,V.Middle,[V.End,V.Start]),y(M,V.End,[V.Start,V.Middle]),y(M,V.Fit,[V.Middle,V.Start,V.End]),M);var Q,tt,et,nt,rt,ot=["active","spacing","align","justify","adjustOnMutation","children","className","popoverZIndex","refEl","usePortal","portalClassName","portalContainer","scrollContainer"],it=["transform"],at=o.css(Q||(Q=w(["\n position: absolute;\n transition: transform ","ms ease-in-out,\n opacity ","ms ease-in-out;\n opacity: 0;\n"])),u.transitionDuration.default,u.transitionDuration.default),ct={attributes:!0,characterData:!0,childList:!0,subtree:!0};function lt(t){var r=t.active,l=void 0!==r&&r,u=t.spacing,s=void 0===u?10:u,d=t.align,g=void 0===d?R.Bottom:d,h=t.justify,P=void 0===h?V.Start:h,E=t.adjustOnMutation,j=void 0!==E&&E,O=t.children,C=t.className,S=t.popoverZIndex,x=t.refEl,D=t.usePortal,H=void 0===D||D,T=t.portalClassName,M=t.portalContainer,L=t.scrollContainer,z=v(t,ot),W=b(e.useState(null),2),I=W[0],A=W[1],k=b(e.useState(null),2),q=k[0],Z=k[1],_=b(e.useState(0),2),G=_[0],J=_[1],U=a.usePopoverContext().setIsPopoverOpen,X=a.usePopoverPortalContainer(),Y=X.portalContainer,$=X.scrollContainer;Y=M||Y,$=L||$,H&&$&&($.contains(Y)||c.consoleOnce.warn("To ensure correct positioning make sure that the portalContainer element is inside of the scrollContainer"));var K=f.default.useRef(q);K.current=q;var Q=null;if(x&&x.current)Q=x.current;else if(I){var lt=I.parentNode;lt&< instanceof HTMLElement&&(Q=lt)}var ut=i.useViewportSize(),st=j&&l,ft=i.useMutationObserver(Q,ct,Date.now,st),dt=i.useMutationObserver(null==q?void 0:q.parentNode,ct,Date.now,st),pt=i.useObjectDependency(N(Q,$,!0)),gt=i.useObjectDependency(N(null==q?void 0:q.parentNode,$)),ht=i.useObjectDependency(e.useMemo((function(){return B(Q,$,!0)}),[Q,$,ut,ft,l,g,P,G])),yt=i.useObjectDependency(e.useMemo((function(){return B(q)}),[null==q?void 0:q.parentNode,ut,dt,l,g,P,G])),mt=i.usePrevious(P),vt=i.usePrevious(g),wt=mt!==P&&(P===V.Fit||mt===V.Fit)||vt!==g&&P===V.Fit;i.useIsomorphicLayoutEffect((function(){wt&&J((function(t){return t+1}))}),[wt]);var bt=b(e.useState(!1),2),Pt=bt[0],Et=bt[1];if(i.useIsomorphicLayoutEffect((function(){return Et(!0)}),[]),!Pt)return null;var jt,Ot=F({useRelativePositioning:!H,spacing:s,align:g,justify:P,referenceElViewportPos:pt,referenceElDocumentPos:ht,contentElViewportPos:gt,contentElDocumentPos:yt,scrollContainer:$}),Ct=Ot.align,St=Ot.justify,xt=Ot.positionCSS,Dt=xt.transform,Ht=v(xt,it),Tt=o.css(tt||(tt=w(["\n opacity: 1;\n position: ",";\n pointer-events: initial;\n "])),H?"":"absolute"),Mt=H?p.default:e.Fragment,Rt=H?Y?{container:Y}:{className:null!=T?T:void 0}:{};return jt=null==O?null:"function"==typeof O?O({align:Ct,justify:St,referenceElPos:ht}):O,f.default.createElement(n.Transition,{nodeRef:K,in:l,timeout:150,mountOnEnter:!0,unmountOnExit:!0,appear:!0,onEntered:function(){return U(!0)},onExit:function(){return U(!1)}},(function(t){var e;return f.default.createElement(f.default.Fragment,null,f.default.createElement("span",{ref:A,className:o.css(et||(et=w(["\n display: none;\n "])))}),f.default.createElement(Mt,Rt,f.default.createElement("div",m({},z,{className:o.cx(at,o.css(Ht),(e={},y(e,o.css({transform:Dt}),"entering"===t||"exiting"===t),y(e,Tt,"entered"===t),y(e,o.css(nt||(nt=w(["\n z-index: ",";\n "])),S),"number"==typeof S),e),C,y({},o.css(rt||(rt=w(["\n transition-delay: 0ms;\n "]))),"exiting"===t))}),f.default.createElement("div",{ref:Z},jt))))}))}lt.displayName="Popover",lt.propTypes={children:d.default.oneOfType([d.default.node,d.default.func]),active:d.default.bool,className:d.default.string,align:d.default.oneOf(Object.values(R)),justify:d.default.oneOf(Object.values(V)),refEl:d.default.shape({current:"undefined"!=typeof window?d.default.instanceOf(Element):d.default.any}),usePortal:d.default.bool,portalClassName:d.default.string,spacing:d.default.number,adjustOnMutation:d.default.bool},t.Align=R,t.Justify=V,t.default=lt,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-transition-group"),require("prop-types"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/leafygreen-provider"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/portal"),require("@leafygreen-ui/tokens")):"function"==typeof define&&define.amd?define(["exports","react","react-transition-group","prop-types","@leafygreen-ui/emotion","@leafygreen-ui/hooks","@leafygreen-ui/leafygreen-provider","@leafygreen-ui/lib","@leafygreen-ui/portal","@leafygreen-ui/tokens"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@leafygreen-ui/popover"]={},t.React,t.reactTransitionGroup,t.PropTypes,t["@leafygreen-ui/emotion"],t["@leafygreen-ui/hooks"],t["@leafygreen-ui/leafygreen-provider"],t["@leafygreen-ui/lib"],t["@leafygreen-ui/portal"],t["@leafygreen-ui/tokens"])}(this,(function(t,e,n,r,o,i,a,c,l,u){"use strict";function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var f=s(e),d=s(r),p=s(l);function g(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?g(Object(n),!0).forEach((function(e){y(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function y(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function m(){return m=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},m.apply(this,arguments)}function v(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function w(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function b(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,c=[],l=!0,u=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(c.push(r.value),c.length!==e);l=!0);}catch(t){u=!0,o=t}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||E(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t){return function(t){if(Array.isArray(t))return j(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||E(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t,e){if(t){if("string"==typeof t)return j(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?j(t,e):void 0}}function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var O,C,S,x,D,H,T,M,R={Top:"top",Bottom:"bottom",Left:"left",Right:"right",CenterVertical:"center-vertical",CenterHorizontal:"center-horizontal"},V={Start:"start",Middle:"middle",End:"end",Fit:"fit"};function F(t){var e=t.useRelativePositioning,n=t.spacing,r=t.align,o=t.justify,i=t.referenceElViewportPos,a=void 0===i?L:i,c=t.referenceElDocumentPos,l=void 0===c?L:c,u=t.contentElViewportPos,s=void 0===u?L:u,f=t.contentElDocumentPos,d=void 0===f?L:f,p=t.scrollContainer,g=t.windowHeight,y=void 0===g?window.innerHeight:g,m=t.windowWidth,v=void 0===m?window.innerWidth:m,w=p?p.offsetWidth:v,b=p?p.offsetHeight:y,E={windowWidth:w,windowHeight:b,referenceElViewportPos:a,contentElViewportPos:s,spacing:n},j=function(t,e){var n=e.spacing,r=e.windowWidth,o=e.windowHeight,i=e.contentElViewportPos,a=e.referenceElViewportPos;return[t].concat(P($[t])).find((function(t){return[R.Top,R.Bottom,R.CenterVertical].includes(t)?Y({top:J({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowHeight:o,contentHeight:i.height}):!![R.Left,R.Right,R.CenterHorizontal].includes(t)&&X({left:U({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowWidth:r,contentWidth:i.width})}))||t}(r,E),O=function(t,e,n){var r,o,i=n.spacing,a=n.windowWidth,c=n.windowHeight,l=n.contentElViewportPos,u=n.referenceElViewportPos,s=[t].concat(P(K[t]));switch(e){case R.Top:case R.Bottom:case R.CenterVertical:return null!==(r=s.find((function(t){return X({contentWidth:t===V.Fit?u.width:l.width,windowWidth:a,left:U({contentElPos:l,referenceElPos:u,spacing:i,align:e,justify:t})})})))&&void 0!==r?r:K[t][0];case R.Left:case R.Right:case R.CenterHorizontal:return null!==(o=s.find((function(t){return Y({contentHeight:t===V.Fit?u.height:l.height,windowHeight:c,top:J({contentElPos:l,referenceElPos:u,spacing:i,align:e,justify:t})})})))&&void 0!==o?o:K[t][0]}}(o,j,E),C=function(t){var e,n,r=t.align,o=t.justify,i=A[r],a=null!==(e=i.x)&&void 0!==e?e:I[o],c=null!==(n=i.y)&&void 0!==n?n:W[o];return"".concat(a," ").concat(c)}({align:j,justify:O}),S=function(t,e){var n=.8;switch(t){case R.Top:return"translate3d(0, ".concat(e,"px, 0) scale(").concat(n,")");case R.Bottom:return"translate3d(0, -".concat(e,"px, 0) scale(").concat(n,")");case R.Left:return"translate3d(".concat(e,"px, 0, 0) scale(").concat(n,")");case R.Right:return"translate3d(-".concat(e,"px, 0, 0) scale(").concat(n,")");case R.CenterHorizontal:case R.CenterVertical:return"scale(".concat(n,")")}}(j,n);return 0===Math.floor(s.width)&&o!==V.Fit?{align:r,justify:o,positionCSS:{left:0,top:0,transform:S,transformOrigin:C}}:e?{align:j,justify:O,positionCSS:h(h({},_({align:j,justify:O,referenceElDocumentPos:l,contentElDocumentPos:d,spacing:n})),{},{transformOrigin:C,transform:S})}:{align:j,justify:O,positionCSS:h(h({},G({align:j,justify:O,referenceElDocumentPos:l,contentElDocumentPos:d,spacing:n,windowHeight:b,windowWidth:w})),{},{transformOrigin:C,transform:S})}}var L={top:0,bottom:0,left:0,right:0,height:0,width:0},z=function(t,e){var n=t.getBoundingClientRect(),r=n.top,o=n.bottom,i=n.left,a=n.right,c=n.width;return{top:r,bottom:o,left:i,right:a,height:t.offsetHeight,width:e?c:parseFloat(getComputedStyle(t).width)}};function B(t,e,n){if(!t)return L;var r=z(t,n),o=r.top,i=r.bottom,a=r.left,c=r.right,l=r.height,u=r.width;if(e){var s=e.scrollTop,f=e.scrollLeft,d=e.getBoundingClientRect();return{top:o+s-d.top,bottom:i+s-d.bottom,left:a+f-d.left,right:c+f-d.right,height:l,width:u}}var p=window,g=p.scrollX,h=p.scrollY;return{top:o+h,bottom:i+h,left:a+g,right:c+g,height:l,width:u}}function N(t,e,n){if(!t)return L;var r=z(t,n),o=r.top,i=r.bottom,a=r.left,c=r.right,l=r.height,u=r.width;if(e){var s=e.getBoundingClientRect();return{top:o-s.top,bottom:i-s.bottom,left:a-s.left,right:c-s.right,height:l,width:u}}return{top:o,bottom:i,left:a,right:c,height:l,width:u}}var W=(y(O={},V.Start,"top"),y(O,V.Middle,"center"),y(O,V.End,"bottom"),y(O,V.Fit,"center"),O),I=(y(C={},V.Start,"left"),y(C,V.Middle,"center"),y(C,V.End,"right"),y(C,V.Fit,"center"),C),A=(y(S={},R.Left,{x:"right"}),y(S,R.Right,{x:"left"}),y(S,R.Top,{y:"bottom"}),y(S,R.Bottom,{y:"top"}),y(S,R.CenterHorizontal,{x:"center"}),y(S,R.CenterVertical,{y:"center"}),S);var k=(y(x={},V.Start,{top:0}),y(x,V.End,{bottom:0}),y(x,V.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{top:"".concat(n.height/2-e.height/2,"px")}})),y(x,V.Fit,{top:0,bottom:0}),x),q=(y(D={},V.Start,{left:0}),y(D,V.End,{right:0}),y(D,V.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{left:"".concat(n.width/2-e.width/2,"px")}})),y(D,V.Fit,{left:0,right:0}),D),Z=(y(H={},R.Top,{constant:function(t){var e=t.spacing;return{bottom:"calc(100% + ".concat(e,"px)")}},justifyPositions:q}),y(H,R.Bottom,{constant:function(t){var e=t.spacing;return{top:"calc(100% + ".concat(e,"px)")}},justifyPositions:q}),y(H,R.CenterVertical,{constant:function(t){var e=t.referenceElDocumentPos;return{top:"calc(".concat(e.height/2,"px - 50%)")}},justifyPositions:q}),y(H,R.Left,{constant:function(t){var e=t.spacing;return{right:"calc(100% + ".concat(e,"px)")}},justifyPositions:k}),y(H,R.Right,{constant:function(t){var e=t.spacing;return{left:"calc(100% + ".concat(e,"px)")}},justifyPositions:k}),y(H,R.CenterHorizontal,{constant:function(t){var e=t.referenceElDocumentPos;return{left:"calc(".concat(e.width/2,"px - 50%)")}},justifyPositions:k}),H);function _(t){var e,n=t.align,r=t.justify,o=t.referenceElDocumentPos,i=t.contentElDocumentPos,a=t.spacing,c=Z[n],l=c.justifyPositions[r],u={contentElDocumentPos:i,referenceElDocumentPos:o,spacing:a};return h(h({},null===(e=c.constant)||void 0===e?void 0:e.call(c,u)),"function"==typeof l?l(u):l)}function G(t){var e=t.align,n=t.justify,r=t.referenceElDocumentPos,o=t.contentElDocumentPos,i=t.spacing,a=t.windowWidth,c=t.windowHeight,l=U({align:e,justify:n,referenceElPos:r,contentElPos:o,spacing:i}),u="".concat(l,"px"),s="".concat(J({align:e,justify:n,referenceElPos:r,contentElPos:o,spacing:i}),"px");return n!==V.Fit?{left:u,top:s}:[R.Left,R.Right,R.CenterHorizontal].includes(e)?{left:u,top:s,bottom:"".concat(c-r.bottom,"px")}:{left:u,top:s,right:"".concat(a-(l+r.width),"px")}}function J(t){var e=t.align,n=t.justify,r=t.contentElPos,o=t.referenceElPos,i=t.spacing;switch(e){case R.Left:case R.Right:case R.CenterHorizontal:switch(n){case V.Start:case V.Fit:return o.top;case V.End:return o.top+o.height-r.height;default:return o.top-(r.height-o.height)/2}case R.CenterVertical:return o.top-(r.height-o.height)/2;case R.Top:return o.top-r.height-i;case R.Bottom:default:return o.top+o.height+i}}function U(t){var e=t.align,n=t.justify,r=t.contentElPos,o=t.referenceElPos,i=t.spacing;switch(e){case R.Top:case R.Bottom:case R.CenterVertical:switch(n){case V.End:return o.left+o.width-r.width;case V.Middle:return o.left-(r.width-o.width)/2;default:return o.left}case R.Left:return o.left-r.width-i;case R.Right:return o.left+o.width+i;case R.CenterHorizontal:default:return o.left-(r.width-o.width)/2}}function X(t){var e=t.left,n=t.windowWidth,r=t.contentWidth;return e>=0&&!(e+r>n)}function Y(t){var e=t.top,n=t.windowHeight,r=t.contentHeight;return e>=0&&!(e+r>n)}var $=(y(T={},R.Top,[R.Bottom]),y(T,R.Bottom,[R.Top]),y(T,R.Left,[R.Right]),y(T,R.Right,[R.Left]),y(T,R.CenterHorizontal,[R.Left,R.Right]),y(T,R.CenterVertical,[R.Top,R.Bottom]),T);var K=(y(M={},V.Start,[V.End,V.Middle]),y(M,V.Middle,[V.End,V.Start]),y(M,V.End,[V.Start,V.Middle]),y(M,V.Fit,[V.Middle,V.Start,V.End]),M);var Q,tt,et,nt,rt,ot=["active","spacing","align","justify","adjustOnMutation","children","className","popoverZIndex","refEl","usePortal","portalClassName","portalContainer","scrollContainer"],it=["transform"],at=o.css(Q||(Q=w(["\n position: absolute;\n transition: transform ","ms ease-in-out,\n opacity ","ms ease-in-out;\n opacity: 0;\n"])),u.transitionDuration.default,u.transitionDuration.default),ct={attributes:!0,characterData:!0,childList:!0,subtree:!0};function lt(t){var r=t.active,l=void 0!==r&&r,u=t.spacing,s=void 0===u?10:u,d=t.align,g=void 0===d?R.Bottom:d,h=t.justify,P=void 0===h?V.Start:h,E=t.adjustOnMutation,j=void 0!==E&&E,O=t.children,C=t.className,S=t.popoverZIndex,x=t.refEl,D=t.usePortal,H=void 0===D||D,T=t.portalClassName,M=t.portalContainer,L=t.scrollContainer,z=v(t,ot),W=b(e.useState(null),2),I=W[0],A=W[1],k=b(e.useState(null),2),q=k[0],Z=k[1],_=b(e.useState(0),2),G=_[0],J=_[1],U=a.usePopoverContext().setIsPopoverOpen,X=a.usePopoverPortalContainer(),Y=X.portalContainer,$=X.scrollContainer;Y=M||Y,$=L||$,H&&$&&($.contains(Y)||c.consoleOnce.warn("To ensure correct positioning make sure that the portalContainer element is inside of the scrollContainer"));var K=f.default.useRef(q);K.current=q;var Q=null;if(x&&x.current)Q=x.current;else if(I){var lt=I.parentNode;lt&< instanceof HTMLElement&&(Q=lt)}var ut=i.useViewportSize(),st=j&&l,ft=i.useMutationObserver(Q,ct,Date.now,st),dt=i.useMutationObserver(null==q?void 0:q.parentNode,ct,Date.now,st),pt=i.useObjectDependency(N(Q,$,!0)),gt=i.useObjectDependency(N(null==q?void 0:q.parentNode,$)),ht=i.useObjectDependency(e.useMemo((function(){return B(Q,$,!0)}),[Q,$,ut,ft,l,g,P,G])),yt=i.useObjectDependency(e.useMemo((function(){return B(q)}),[null==q?void 0:q.parentNode,ut,dt,l,g,P,G])),mt=i.usePrevious(P),vt=i.usePrevious(g),wt=mt!==P&&(P===V.Fit||mt===V.Fit)||vt!==g&&P===V.Fit;i.useIsomorphicLayoutEffect((function(){wt&&J((function(t){return t+1}))}),[wt]);var bt=b(e.useState(!1),2),Pt=bt[0],Et=bt[1];if(i.useIsomorphicLayoutEffect((function(){return Et(!0)}),[]),!Pt)return null;var jt,Ot=F({useRelativePositioning:!H,spacing:s,align:g,justify:P,referenceElViewportPos:pt,referenceElDocumentPos:ht,contentElViewportPos:gt,contentElDocumentPos:yt,scrollContainer:$}),Ct=Ot.align,St=Ot.justify,xt=Ot.positionCSS,Dt=xt.transform,Ht=v(xt,it),Tt=o.css(tt||(tt=w(["\n opacity: 1;\n position: ",";\n pointer-events: initial;\n "])),H?"":"absolute"),Mt=H?p.default:e.Fragment,Rt=H?Y?{container:Y}:{className:null!=T?T:void 0}:{};return jt=null==O?null:"function"==typeof O?O({align:Ct,justify:St,referenceElPos:ht}):O,f.default.createElement(n.Transition,{nodeRef:K,in:l,timeout:150,mountOnEnter:!0,unmountOnExit:!0,appear:!0,onEntered:function(){return U(!0)},onExit:function(){return U(!1)}},(function(t){var e;return f.default.createElement(f.default.Fragment,null,f.default.createElement("span",{ref:A,className:o.css(et||(et=w(["\n display: none;\n "])))}),f.default.createElement(Mt,Rt,f.default.createElement("div",m({},z,{className:o.cx(at,o.css(Ht),(e={},y(e,o.css({transform:Dt}),"entering"===t||"exiting"===t),y(e,Tt,"entered"===t),y(e,o.css(nt||(nt=w(["\n z-index: ",";\n "])),S),"number"==typeof S),e),C,y({},o.css(rt||(rt=w(["\n transition-delay: 0ms;\n "]))),"exiting"===t))}),f.default.createElement("div",{ref:Z},jt))))}))}lt.displayName="Popover",lt.propTypes={children:d.default.oneOfType([d.default.node,d.default.func]),active:d.default.bool,className:d.default.string,align:d.default.oneOf(Object.values(R)),justify:d.default.oneOf(Object.values(V)),refEl:d.default.shape({current:"undefined"!=typeof window?d.default.instanceOf(Element):d.default.any}),usePortal:d.default.bool,portalClassName:d.default.string,spacing:d.default.number,adjustOnMutation:d.default.bool},t.Align=R,t.Justify=V,t.default=lt,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@leafygreen-ui/popover", | ||
"version": "11.0.9", | ||
"version": "11.0.10-next.0", | ||
"description": "LeafyGreen UI Kit Popover", | ||
@@ -24,5 +24,5 @@ "main": "./dist/index.js", | ||
"@leafygreen-ui/emotion": "^4.0.4", | ||
"@leafygreen-ui/hooks": "^7.7.2", | ||
"@leafygreen-ui/lib": "^10.3.3", | ||
"@leafygreen-ui/portal": "^4.1.2", | ||
"@leafygreen-ui/hooks": "^7.7.4-next.0", | ||
"@leafygreen-ui/lib": "^10.3.4-next.0", | ||
"@leafygreen-ui/portal": "^4.1.3-next.0", | ||
"@leafygreen-ui/tokens": "^2.1.0", | ||
@@ -32,3 +32,3 @@ "react-transition-group": "^4.4.1" | ||
"peerDependencies": { | ||
"@leafygreen-ui/leafygreen-provider": "^3.1.2" | ||
"@leafygreen-ui/leafygreen-provider": "^3.1.3-next.0" | ||
}, | ||
@@ -46,4 +46,4 @@ "gitHead": "dd71a2d404218ccec2e657df9c0263dc1c15b9e0", | ||
"@leafygreen-ui/palette": "^4.0.4", | ||
"@leafygreen-ui/button": "^20.0.6" | ||
"@leafygreen-ui/button": "^20.0.8-next.0" | ||
} | ||
} |
@@ -1,1 +0,1 @@ | ||
import t,{useState as e,useMemo as n,Fragment as o,useRef as r}from"react";import i from"@leafygreen-ui/button";import{css as a,cx as c}from"@leafygreen-ui/emotion";import{consoleOnce as l,StoryMeta as s}from"@leafygreen-ui/lib";import{palette as u}from"@leafygreen-ui/palette";import{Transition as f}from"react-transition-group";import p from"prop-types";import{useViewportSize as d,useMutationObserver as h,useObjectDependency as g,usePrevious as m,useIsomorphicLayoutEffect as v}from"@leafygreen-ui/hooks";import{usePopoverContext as y,usePopoverPortalContainer as w}from"@leafygreen-ui/leafygreen-provider";import b from"@leafygreen-ui/portal";import{transitionDuration as E}from"@leafygreen-ui/tokens";function P(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function j(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?P(Object(n),!0).forEach((function(e){O(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function O(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C(){return C=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},C.apply(this,arguments)}function x(t,e){if(null==t)return{};var n,o,r=function(t,e){if(null==t)return{};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function S(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function D(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var o,r,i=[],a=!0,c=!1;try{for(n=n.call(t);!(a=(o=n.next()).done)&&(i.push(o.value),!e||i.length!==e);a=!0);}catch(t){c=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(c)throw r}}return i}(t,e)||H(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(t){return function(t){if(Array.isArray(t))return N(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||H(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(t,e){if(t){if("string"==typeof t)return N(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?N(t,e):void 0}}function N(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}var B,V,R,M,F,z,L,W,k={Top:"top",Bottom:"bottom",Left:"left",Right:"right",CenterVertical:"center-vertical",CenterHorizontal:"center-horizontal"},A={Start:"start",Middle:"middle",End:"end",Fit:"fit"};function I(t){var e=t.useRelativePositioning,n=t.spacing,o=t.align,r=t.justify,i=t.referenceElViewportPos,a=void 0===i?U:i,c=t.referenceElDocumentPos,l=void 0===c?U:c,s=t.contentElViewportPos,u=void 0===s?U:s,f=t.contentElDocumentPos,p=void 0===f?U:f,d=t.scrollContainer,h=t.windowHeight,g=void 0===h?window.innerHeight:h,m=t.windowWidth,v=void 0===m?window.innerWidth:m,y=d?d.offsetWidth:v,w=d?d.offsetHeight:g,b={windowWidth:y,windowHeight:w,referenceElViewportPos:a,contentElViewportPos:u,spacing:n},E=function(t,e){var n=e.spacing,o=e.windowWidth,r=e.windowHeight,i=e.contentElViewportPos,a=e.referenceElViewportPos;return[t].concat(T(it[t])).find((function(t){return[k.Top,k.Bottom,k.CenterVertical].includes(t)?rt({top:et({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowHeight:r,contentHeight:i.height}):!![k.Left,k.Right,k.CenterHorizontal].includes(t)&&ot({left:nt({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowWidth:o,contentWidth:i.width})}))||t}(o,b),P=function(t,e,n){var o,r,i=n.spacing,a=n.windowWidth,c=n.windowHeight,l=n.contentElViewportPos,s=n.referenceElViewportPos,u=[t].concat(T(at[t]));switch(e){case k.Top:case k.Bottom:case k.CenterVertical:return null!==(o=u.find((function(t){return ot({contentWidth:t===A.Fit?s.width:l.width,windowWidth:a,left:nt({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==o?o:at[t][0];case k.Left:case k.Right:case k.CenterHorizontal:return null!==(r=u.find((function(t){return rt({contentHeight:t===A.Fit?s.height:l.height,windowHeight:c,top:et({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==r?r:at[t][0]}}(r,E,b),O=function(t){var e,n,o=t.align,r=t.justify,i=G[o],a=null!==(e=i.x)&&void 0!==e?e:q[r],c=null!==(n=i.y)&&void 0!==n?n:$[r];return"".concat(a," ").concat(c)}({align:E,justify:P}),C=function(t,e){var n=.8;switch(t){case k.Top:return"translate3d(0, ".concat(e,"px, 0) scale(").concat(n,")");case k.Bottom:return"translate3d(0, -".concat(e,"px, 0) scale(").concat(n,")");case k.Left:return"translate3d(".concat(e,"px, 0, 0) scale(").concat(n,")");case k.Right:return"translate3d(-".concat(e,"px, 0, 0) scale(").concat(n,")");case k.CenterHorizontal:case k.CenterVertical:return"scale(".concat(n,")")}}(E,n);return 0===Math.floor(u.width)&&r!==A.Fit?{align:o,justify:r,positionCSS:{left:0,top:0,transform:C,transformOrigin:O}}:e?{align:E,justify:P,positionCSS:j(j({},_({align:E,justify:P,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n})),{},{transformOrigin:O,transform:C})}:{align:E,justify:P,positionCSS:j(j({},tt({align:E,justify:P,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n,windowHeight:w,windowWidth:y})),{},{transformOrigin:O,transform:C})}}var U={top:0,bottom:0,left:0,right:0,height:0,width:0},Z=function(t,e){var n=t.getBoundingClientRect(),o=n.top,r=n.bottom,i=n.left,a=n.right,c=n.width;return{top:o,bottom:r,left:i,right:a,height:t.offsetHeight,width:e?c:parseFloat(getComputedStyle(t).width)}};function X(t,e,n){if(!t)return U;var o=Z(t,n),r=o.top,i=o.bottom,a=o.left,c=o.right,l=o.height,s=o.width;if(e){var u=e.scrollTop,f=e.scrollLeft,p=e.getBoundingClientRect();return{top:r+u-p.top,bottom:i+u-p.bottom,left:a+f-p.left,right:c+f-p.right,height:l,width:s}}var d=window,h=d.scrollX,g=d.scrollY;return{top:r+g,bottom:i+g,left:a+h,right:c+h,height:l,width:s}}function Y(t,e,n){if(!t)return U;var o=Z(t,n),r=o.top,i=o.bottom,a=o.left,c=o.right,l=o.height,s=o.width;if(e){var u=e.getBoundingClientRect();return{top:r-u.top,bottom:i-u.bottom,left:a-u.left,right:c-u.right,height:l,width:s}}return{top:r,bottom:i,left:a,right:c,height:l,width:s}}var $=(O(B={},A.Start,"top"),O(B,A.Middle,"center"),O(B,A.End,"bottom"),O(B,A.Fit,"center"),B),q=(O(V={},A.Start,"left"),O(V,A.Middle,"center"),O(V,A.End,"right"),O(V,A.Fit,"center"),V),G=(O(R={},k.Left,{x:"right"}),O(R,k.Right,{x:"left"}),O(R,k.Top,{y:"bottom"}),O(R,k.Bottom,{y:"top"}),O(R,k.CenterHorizontal,{x:"center"}),O(R,k.CenterVertical,{y:"center"}),R);var J=(O(M={},A.Start,{top:0}),O(M,A.End,{bottom:0}),O(M,A.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{top:"".concat(n.height/2-e.height/2,"px")}})),O(M,A.Fit,{top:0,bottom:0}),M),K=(O(F={},A.Start,{left:0}),O(F,A.End,{right:0}),O(F,A.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{left:"".concat(n.width/2-e.width/2,"px")}})),O(F,A.Fit,{left:0,right:0}),F),Q=(O(z={},k.Top,{constant:function(t){var e=t.spacing;return{bottom:"calc(100% + ".concat(e,"px)")}},justifyPositions:K}),O(z,k.Bottom,{constant:function(t){var e=t.spacing;return{top:"calc(100% + ".concat(e,"px)")}},justifyPositions:K}),O(z,k.CenterVertical,{constant:function(t){var e=t.referenceElDocumentPos;return{top:"calc(".concat(e.height/2,"px - 50%)")}},justifyPositions:K}),O(z,k.Left,{constant:function(t){var e=t.spacing;return{right:"calc(100% + ".concat(e,"px)")}},justifyPositions:J}),O(z,k.Right,{constant:function(t){var e=t.spacing;return{left:"calc(100% + ".concat(e,"px)")}},justifyPositions:J}),O(z,k.CenterHorizontal,{constant:function(t){var e=t.referenceElDocumentPos;return{left:"calc(".concat(e.width/2,"px - 50%)")}},justifyPositions:J}),z);function _(t){var e,n=t.align,o=t.justify,r=t.referenceElDocumentPos,i=t.contentElDocumentPos,a=t.spacing,c=Q[n],l=c.justifyPositions[o],s={contentElDocumentPos:i,referenceElDocumentPos:r,spacing:a};return j(j({},null===(e=c.constant)||void 0===e?void 0:e.call(c,s)),"function"==typeof l?l(s):l)}function tt(t){var e=t.align,n=t.justify,o=t.referenceElDocumentPos,r=t.contentElDocumentPos,i=t.spacing,a=t.windowWidth,c=t.windowHeight,l=nt({align:e,justify:n,referenceElPos:o,contentElPos:r,spacing:i}),s="".concat(l,"px"),u="".concat(et({align:e,justify:n,referenceElPos:o,contentElPos:r,spacing:i}),"px");return n!==A.Fit?{left:s,top:u}:[k.Left,k.Right,k.CenterHorizontal].includes(e)?{left:s,top:u,bottom:"".concat(c-o.bottom,"px")}:{left:s,top:u,right:"".concat(a-(l+o.width),"px")}}function et(t){var e=t.align,n=t.justify,o=t.contentElPos,r=t.referenceElPos,i=t.spacing;switch(e){case k.Left:case k.Right:case k.CenterHorizontal:switch(n){case A.Start:case A.Fit:return r.top;case A.End:return r.top+r.height-o.height;default:return r.top-(o.height-r.height)/2}case k.CenterVertical:return r.top-(o.height-r.height)/2;case k.Top:return r.top-o.height-i;case k.Bottom:default:return r.top+r.height+i}}function nt(t){var e=t.align,n=t.justify,o=t.contentElPos,r=t.referenceElPos,i=t.spacing;switch(e){case k.Top:case k.Bottom:case k.CenterVertical:switch(n){case A.End:return r.left+r.width-o.width;case A.Middle:return r.left-(o.width-r.width)/2;default:return r.left}case k.Left:return r.left-o.width-i;case k.Right:return r.left+r.width+i;case k.CenterHorizontal:default:return r.left-(o.width-r.width)/2}}function ot(t){var e=t.left,n=t.windowWidth,o=t.contentWidth;return e>=0&&!(e+o>n)}function rt(t){var e=t.top,n=t.windowHeight,o=t.contentHeight;return e>=0&&!(e+o>n)}var it=(O(L={},k.Top,[k.Bottom]),O(L,k.Bottom,[k.Top]),O(L,k.Left,[k.Right]),O(L,k.Right,[k.Left]),O(L,k.CenterHorizontal,[k.Left,k.Right]),O(L,k.CenterVertical,[k.Top,k.Bottom]),L);var at=(O(W={},A.Start,[A.End,A.Middle]),O(W,A.Middle,[A.End,A.Start]),O(W,A.End,[A.Start,A.Middle]),O(W,A.Fit,[A.Middle,A.Start,A.End]),W);var ct,lt,st,ut,ft,pt=["active","spacing","align","justify","adjustOnMutation","children","className","popoverZIndex","refEl","usePortal","portalClassName","portalContainer","scrollContainer"],dt=["transform"],ht=a(ct||(ct=S(["\n position: absolute;\n transition: transform ","ms ease-in-out,\n opacity ","ms ease-in-out;\n opacity: 0;\n"])),E.default,E.default),gt={attributes:!0,characterData:!0,childList:!0,subtree:!0};function mt(r){var i=r.active,s=void 0!==i&&i,u=r.spacing,p=void 0===u?10:u,E=r.align,P=void 0===E?k.Bottom:E,j=r.justify,T=void 0===j?A.Start:j,H=r.adjustOnMutation,N=void 0!==H&&H,B=r.children,V=r.className,R=r.popoverZIndex,M=r.refEl,F=r.usePortal,z=void 0===F||F,L=r.portalClassName,W=r.portalContainer,U=r.scrollContainer,Z=x(r,pt),$=D(e(null),2),q=$[0],G=$[1],J=D(e(null),2),K=J[0],Q=J[1],_=D(e(0),2),tt=_[0],et=_[1],nt=y().setIsPopoverOpen,ot=w(),rt=ot.portalContainer,it=ot.scrollContainer;rt=W||rt,it=U||it,z&&it&&(it.contains(rt)||l.warn("To ensure correct positioning make sure that the portalContainer element is inside of the scrollContainer"));var at=t.useRef(K);at.current=K;var ct=null;if(M&&M.current)ct=M.current;else if(q){var mt=q.parentNode;mt&&mt instanceof HTMLElement&&(ct=mt)}var vt=d(),yt=N&&s,wt=h(ct,gt,Date.now,yt),bt=h(null==K?void 0:K.parentNode,gt,Date.now,yt),Et=g(Y(ct,it,!0)),Pt=g(Y(null==K?void 0:K.parentNode,it)),jt=g(n((function(){return X(ct,it,!0)}),[ct,it,vt,wt,s,P,T,tt])),Ot=g(n((function(){return X(K)}),[null==K?void 0:K.parentNode,vt,bt,s,P,T,tt])),Ct=m(T),xt=m(P),St=Ct!==T&&(T===A.Fit||Ct===A.Fit)||xt!==P&&T===A.Fit;v((function(){St&&et((function(t){return t+1}))}),[St]);var Dt=D(e(!1),2),Tt=Dt[0],Ht=Dt[1];if(v((function(){return Ht(!0)}),[]),!Tt)return null;var Nt,Bt=I({useRelativePositioning:!z,spacing:p,align:P,justify:T,referenceElViewportPos:Et,referenceElDocumentPos:jt,contentElViewportPos:Pt,contentElDocumentPos:Ot,scrollContainer:it}),Vt=Bt.align,Rt=Bt.justify,Mt=Bt.positionCSS,Ft=Mt.transform,zt=x(Mt,dt),Lt=a(lt||(lt=S(["\n opacity: 1;\n position: ",";\n pointer-events: initial;\n "])),z?"":"absolute"),Wt=z?b:o,kt=z?rt?{container:rt}:{className:null!=L?L:void 0}:{};return Nt=null==B?null:"function"==typeof B?B({align:Vt,justify:Rt,referenceElPos:jt}):B,t.createElement(f,{nodeRef:at,in:s,timeout:150,mountOnEnter:!0,unmountOnExit:!0,appear:!0,onEntered:function(){return nt(!0)},onExit:function(){return nt(!1)}},(function(e){var n;return t.createElement(t.Fragment,null,t.createElement("span",{ref:G,className:a(st||(st=S(["\n display: none;\n "])))}),t.createElement(Wt,kt,t.createElement("div",C({},Z,{className:c(ht,a(zt),(n={},O(n,a({transform:Ft}),"entering"===e||"exiting"===e),O(n,Lt,"entered"===e),O(n,a(ut||(ut=S(["\n z-index: ",";\n "])),R),"number"==typeof R),n),V,O({},a(ft||(ft=S(["\n transition-delay: 0ms;\n "]))),"exiting"===e))}),t.createElement("div",{ref:Q},Nt))))}))}mt.displayName="Popover",mt.propTypes={children:p.oneOfType([p.node,p.func]),active:p.bool,className:p.string,align:p.oneOf(Object.values(k)),justify:p.oneOf(Object.values(A)),refEl:p.shape({current:"undefined"!=typeof window?p.instanceOf(Element):p.any}),usePortal:p.bool,portalClassName:p.string,spacing:p.number,adjustOnMutation:p.bool};var vt,yt,wt,bt,Et,Pt,jt,Ot,Ct,xt,St=["refButtonPosition","buttonText"],Dt=["refButtonPosition","buttonText"],Tt=a(vt||(vt=S(["\n border: 1px solid ",";\n text-align: center;\n padding: 20px;\n max-height: 100%;\n overflow: hidden;\n // Reset these properties since they'll be inherited\n // from the container element when not using a portal.\n font-size: initial;\n color: initial;\n background-color: initial;\n"])),u.gray.light1),Ht=a(yt||(yt=S(["\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"]))),Nt=a(wt||(wt=S(["\n width: 500px;\n height: 90vh;\n background-color: ",";\n overflow: scroll;\n position: relative;\n"])),u.gray.light2),Bt=a(bt||(bt=S(["\n position: relative;\n height: 130vh;\n display: flex;\n align-items: center;\n justify-content: center;\n"]))),Vt=a(Et||(Et=S(["\n position: relative;\n"]))),Rt={centered:a(Pt||(Pt=S(["\n position: relative;\n "]))),top:a(jt||(jt=S(["\n top: 0;\n position: absolute;\n "]))),right:a(Ot||(Ot=S(["\n right: 0;\n position: absolute;\n "]))),bottom:a(Ct||(Ct=S(["\n bottom: 0;\n position: absolute;\n "]))),left:a(xt||(xt=S(["\n left: 0;\n position: absolute;\n "])))},Mt=s({title:"Components/Popover",component:mt,args:{align:k.Top,justify:A.Start,usePortal:!0,spacing:10,adjustOnMutation:!1},argTypes:{buttonText:{type:"string",description:"Storybook only prop. Used to change the reference button text",defaultValue:"Button Text"},refButtonPosition:{options:["centered","top","right","bottom","left"],control:{type:"select"},description:"Storybook only prop. Used to change position of the reference button",defaultValue:"centered"}},parameters:{default:"Basic",controls:{exclude:["children","active","refEl","portalClassName","refButtonPosition","usePortal"]}}}),Ft=function(n){var o=n.refButtonPosition,r=n.buttonText,a=x(n,St),l=D(e(!1),2),s=l[0],u=l[1],f=Rt[o];return t.createElement("div",{className:Ht},t.createElement(i,{className:c(Vt,f),onClick:function(){return u((function(t){return!t}))}},r,t.createElement(mt,C({},a,{active:s}),t.createElement("div",{className:Tt},"Popover content"))))},zt=function(n){var o=n.refButtonPosition,a=n.buttonText,c=x(n,Dt),l=D(e(!1),2),s=l[0],u=l[1],f=r(null),p=Rt[o];return t.createElement("div",{className:Nt},t.createElement("div",{className:Bt,ref:f},t.createElement(i,{onClick:function(){return u((function(t){return!t}))},className:p},a,t.createElement(mt,C({},c,{active:s,portalContainer:f.current,scrollContainer:f.current}),t.createElement("div",{className:Tt},"Popover content")))))};zt.args={usePortal:!0},zt.argTypes={usePortal:{control:"none"},portalClassName:{control:"none"},refEl:{control:"none"},className:{control:"none"},active:{control:"none"}};export{Ft as Basic,zt as ScrollableContainer,Mt as default}; | ||
import t,{useState as e,useMemo as n,Fragment as o,useRef as r}from"react";import i from"@leafygreen-ui/button";import{css as a,cx as c}from"@leafygreen-ui/emotion";import{consoleOnce as l,storybookExcludedControlParams as s}from"@leafygreen-ui/lib";import{palette as u}from"@leafygreen-ui/palette";import{Transition as f}from"react-transition-group";import p from"prop-types";import{useViewportSize as d,useMutationObserver as g,useObjectDependency as h,usePrevious as m,useIsomorphicLayoutEffect as v}from"@leafygreen-ui/hooks";import{usePopoverContext as y,usePopoverPortalContainer as w}from"@leafygreen-ui/leafygreen-provider";import b from"@leafygreen-ui/portal";import{transitionDuration as E}from"@leafygreen-ui/tokens";function P(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function j(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?P(Object(n),!0).forEach((function(e){O(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function O(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C(){return C=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},C.apply(this,arguments)}function x(t,e){if(null==t)return{};var n,o,r=function(t,e){if(null==t)return{};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function S(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function T(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var o,r,i,a,c=[],l=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(o=i.call(n)).done)&&(c.push(o.value),c.length!==e);l=!0);}catch(t){s=!0,r=t}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw r}}return c}}(t,e)||H(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(t){return function(t){if(Array.isArray(t))return N(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||H(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(t,e){if(t){if("string"==typeof t)return N(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?N(t,e):void 0}}function N(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}var B,R,V,M,F,z,L,W,k={Top:"top",Bottom:"bottom",Left:"left",Right:"right",CenterVertical:"center-vertical",CenterHorizontal:"center-horizontal"},A={Start:"start",Middle:"middle",End:"end",Fit:"fit"};function I(t){var e=t.useRelativePositioning,n=t.spacing,o=t.align,r=t.justify,i=t.referenceElViewportPos,a=void 0===i?U:i,c=t.referenceElDocumentPos,l=void 0===c?U:c,s=t.contentElViewportPos,u=void 0===s?U:s,f=t.contentElDocumentPos,p=void 0===f?U:f,d=t.scrollContainer,g=t.windowHeight,h=void 0===g?window.innerHeight:g,m=t.windowWidth,v=void 0===m?window.innerWidth:m,y=d?d.offsetWidth:v,w=d?d.offsetHeight:h,b={windowWidth:y,windowHeight:w,referenceElViewportPos:a,contentElViewportPos:u,spacing:n},E=function(t,e){var n=e.spacing,o=e.windowWidth,r=e.windowHeight,i=e.contentElViewportPos,a=e.referenceElViewportPos;return[t].concat(D(it[t])).find((function(t){return[k.Top,k.Bottom,k.CenterVertical].includes(t)?rt({top:et({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowHeight:r,contentHeight:i.height}):!![k.Left,k.Right,k.CenterHorizontal].includes(t)&&ot({left:nt({align:t,contentElPos:i,referenceElPos:a,spacing:n}),windowWidth:o,contentWidth:i.width})}))||t}(o,b),P=function(t,e,n){var o,r,i=n.spacing,a=n.windowWidth,c=n.windowHeight,l=n.contentElViewportPos,s=n.referenceElViewportPos,u=[t].concat(D(at[t]));switch(e){case k.Top:case k.Bottom:case k.CenterVertical:return null!==(o=u.find((function(t){return ot({contentWidth:t===A.Fit?s.width:l.width,windowWidth:a,left:nt({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==o?o:at[t][0];case k.Left:case k.Right:case k.CenterHorizontal:return null!==(r=u.find((function(t){return rt({contentHeight:t===A.Fit?s.height:l.height,windowHeight:c,top:et({contentElPos:l,referenceElPos:s,spacing:i,align:e,justify:t})})})))&&void 0!==r?r:at[t][0]}}(r,E,b),O=function(t){var e,n,o=t.align,r=t.justify,i=G[o],a=null!==(e=i.x)&&void 0!==e?e:q[r],c=null!==(n=i.y)&&void 0!==n?n:$[r];return"".concat(a," ").concat(c)}({align:E,justify:P}),C=function(t,e){var n=.8;switch(t){case k.Top:return"translate3d(0, ".concat(e,"px, 0) scale(").concat(n,")");case k.Bottom:return"translate3d(0, -".concat(e,"px, 0) scale(").concat(n,")");case k.Left:return"translate3d(".concat(e,"px, 0, 0) scale(").concat(n,")");case k.Right:return"translate3d(-".concat(e,"px, 0, 0) scale(").concat(n,")");case k.CenterHorizontal:case k.CenterVertical:return"scale(".concat(n,")")}}(E,n);return 0===Math.floor(u.width)&&r!==A.Fit?{align:o,justify:r,positionCSS:{left:0,top:0,transform:C,transformOrigin:O}}:e?{align:E,justify:P,positionCSS:j(j({},_({align:E,justify:P,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n})),{},{transformOrigin:O,transform:C})}:{align:E,justify:P,positionCSS:j(j({},tt({align:E,justify:P,referenceElDocumentPos:l,contentElDocumentPos:p,spacing:n,windowHeight:w,windowWidth:y})),{},{transformOrigin:O,transform:C})}}var U={top:0,bottom:0,left:0,right:0,height:0,width:0},Z=function(t,e){var n=t.getBoundingClientRect(),o=n.top,r=n.bottom,i=n.left,a=n.right,c=n.width;return{top:o,bottom:r,left:i,right:a,height:t.offsetHeight,width:e?c:parseFloat(getComputedStyle(t).width)}};function X(t,e,n){if(!t)return U;var o=Z(t,n),r=o.top,i=o.bottom,a=o.left,c=o.right,l=o.height,s=o.width;if(e){var u=e.scrollTop,f=e.scrollLeft,p=e.getBoundingClientRect();return{top:r+u-p.top,bottom:i+u-p.bottom,left:a+f-p.left,right:c+f-p.right,height:l,width:s}}var d=window,g=d.scrollX,h=d.scrollY;return{top:r+h,bottom:i+h,left:a+g,right:c+g,height:l,width:s}}function Y(t,e,n){if(!t)return U;var o=Z(t,n),r=o.top,i=o.bottom,a=o.left,c=o.right,l=o.height,s=o.width;if(e){var u=e.getBoundingClientRect();return{top:r-u.top,bottom:i-u.bottom,left:a-u.left,right:c-u.right,height:l,width:s}}return{top:r,bottom:i,left:a,right:c,height:l,width:s}}var $=(O(B={},A.Start,"top"),O(B,A.Middle,"center"),O(B,A.End,"bottom"),O(B,A.Fit,"center"),B),q=(O(R={},A.Start,"left"),O(R,A.Middle,"center"),O(R,A.End,"right"),O(R,A.Fit,"center"),R),G=(O(V={},k.Left,{x:"right"}),O(V,k.Right,{x:"left"}),O(V,k.Top,{y:"bottom"}),O(V,k.Bottom,{y:"top"}),O(V,k.CenterHorizontal,{x:"center"}),O(V,k.CenterVertical,{y:"center"}),V);var J=(O(M={},A.Start,{top:0}),O(M,A.End,{bottom:0}),O(M,A.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{top:"".concat(n.height/2-e.height/2,"px")}})),O(M,A.Fit,{top:0,bottom:0}),M),K=(O(F={},A.Start,{left:0}),O(F,A.End,{right:0}),O(F,A.Middle,(function(t){var e=t.contentElDocumentPos,n=t.referenceElDocumentPos;return{left:"".concat(n.width/2-e.width/2,"px")}})),O(F,A.Fit,{left:0,right:0}),F),Q=(O(z={},k.Top,{constant:function(t){var e=t.spacing;return{bottom:"calc(100% + ".concat(e,"px)")}},justifyPositions:K}),O(z,k.Bottom,{constant:function(t){var e=t.spacing;return{top:"calc(100% + ".concat(e,"px)")}},justifyPositions:K}),O(z,k.CenterVertical,{constant:function(t){var e=t.referenceElDocumentPos;return{top:"calc(".concat(e.height/2,"px - 50%)")}},justifyPositions:K}),O(z,k.Left,{constant:function(t){var e=t.spacing;return{right:"calc(100% + ".concat(e,"px)")}},justifyPositions:J}),O(z,k.Right,{constant:function(t){var e=t.spacing;return{left:"calc(100% + ".concat(e,"px)")}},justifyPositions:J}),O(z,k.CenterHorizontal,{constant:function(t){var e=t.referenceElDocumentPos;return{left:"calc(".concat(e.width/2,"px - 50%)")}},justifyPositions:J}),z);function _(t){var e,n=t.align,o=t.justify,r=t.referenceElDocumentPos,i=t.contentElDocumentPos,a=t.spacing,c=Q[n],l=c.justifyPositions[o],s={contentElDocumentPos:i,referenceElDocumentPos:r,spacing:a};return j(j({},null===(e=c.constant)||void 0===e?void 0:e.call(c,s)),"function"==typeof l?l(s):l)}function tt(t){var e=t.align,n=t.justify,o=t.referenceElDocumentPos,r=t.contentElDocumentPos,i=t.spacing,a=t.windowWidth,c=t.windowHeight,l=nt({align:e,justify:n,referenceElPos:o,contentElPos:r,spacing:i}),s="".concat(l,"px"),u="".concat(et({align:e,justify:n,referenceElPos:o,contentElPos:r,spacing:i}),"px");return n!==A.Fit?{left:s,top:u}:[k.Left,k.Right,k.CenterHorizontal].includes(e)?{left:s,top:u,bottom:"".concat(c-o.bottom,"px")}:{left:s,top:u,right:"".concat(a-(l+o.width),"px")}}function et(t){var e=t.align,n=t.justify,o=t.contentElPos,r=t.referenceElPos,i=t.spacing;switch(e){case k.Left:case k.Right:case k.CenterHorizontal:switch(n){case A.Start:case A.Fit:return r.top;case A.End:return r.top+r.height-o.height;default:return r.top-(o.height-r.height)/2}case k.CenterVertical:return r.top-(o.height-r.height)/2;case k.Top:return r.top-o.height-i;case k.Bottom:default:return r.top+r.height+i}}function nt(t){var e=t.align,n=t.justify,o=t.contentElPos,r=t.referenceElPos,i=t.spacing;switch(e){case k.Top:case k.Bottom:case k.CenterVertical:switch(n){case A.End:return r.left+r.width-o.width;case A.Middle:return r.left-(o.width-r.width)/2;default:return r.left}case k.Left:return r.left-o.width-i;case k.Right:return r.left+r.width+i;case k.CenterHorizontal:default:return r.left-(o.width-r.width)/2}}function ot(t){var e=t.left,n=t.windowWidth,o=t.contentWidth;return e>=0&&!(e+o>n)}function rt(t){var e=t.top,n=t.windowHeight,o=t.contentHeight;return e>=0&&!(e+o>n)}var it=(O(L={},k.Top,[k.Bottom]),O(L,k.Bottom,[k.Top]),O(L,k.Left,[k.Right]),O(L,k.Right,[k.Left]),O(L,k.CenterHorizontal,[k.Left,k.Right]),O(L,k.CenterVertical,[k.Top,k.Bottom]),L);var at=(O(W={},A.Start,[A.End,A.Middle]),O(W,A.Middle,[A.End,A.Start]),O(W,A.End,[A.Start,A.Middle]),O(W,A.Fit,[A.Middle,A.Start,A.End]),W);var ct,lt,st,ut,ft,pt=["active","spacing","align","justify","adjustOnMutation","children","className","popoverZIndex","refEl","usePortal","portalClassName","portalContainer","scrollContainer"],dt=["transform"],gt=a(ct||(ct=S(["\n position: absolute;\n transition: transform ","ms ease-in-out,\n opacity ","ms ease-in-out;\n opacity: 0;\n"])),E.default,E.default),ht={attributes:!0,characterData:!0,childList:!0,subtree:!0};function mt(r){var i=r.active,s=void 0!==i&&i,u=r.spacing,p=void 0===u?10:u,E=r.align,P=void 0===E?k.Bottom:E,j=r.justify,D=void 0===j?A.Start:j,H=r.adjustOnMutation,N=void 0!==H&&H,B=r.children,R=r.className,V=r.popoverZIndex,M=r.refEl,F=r.usePortal,z=void 0===F||F,L=r.portalClassName,W=r.portalContainer,U=r.scrollContainer,Z=x(r,pt),$=T(e(null),2),q=$[0],G=$[1],J=T(e(null),2),K=J[0],Q=J[1],_=T(e(0),2),tt=_[0],et=_[1],nt=y().setIsPopoverOpen,ot=w(),rt=ot.portalContainer,it=ot.scrollContainer;rt=W||rt,it=U||it,z&&it&&(it.contains(rt)||l.warn("To ensure correct positioning make sure that the portalContainer element is inside of the scrollContainer"));var at=t.useRef(K);at.current=K;var ct=null;if(M&&M.current)ct=M.current;else if(q){var mt=q.parentNode;mt&&mt instanceof HTMLElement&&(ct=mt)}var vt=d(),yt=N&&s,wt=g(ct,ht,Date.now,yt),bt=g(null==K?void 0:K.parentNode,ht,Date.now,yt),Et=h(Y(ct,it,!0)),Pt=h(Y(null==K?void 0:K.parentNode,it)),jt=h(n((function(){return X(ct,it,!0)}),[ct,it,vt,wt,s,P,D,tt])),Ot=h(n((function(){return X(K)}),[null==K?void 0:K.parentNode,vt,bt,s,P,D,tt])),Ct=m(D),xt=m(P),St=Ct!==D&&(D===A.Fit||Ct===A.Fit)||xt!==P&&D===A.Fit;v((function(){St&&et((function(t){return t+1}))}),[St]);var Tt=T(e(!1),2),Dt=Tt[0],Ht=Tt[1];if(v((function(){return Ht(!0)}),[]),!Dt)return null;var Nt,Bt=I({useRelativePositioning:!z,spacing:p,align:P,justify:D,referenceElViewportPos:Et,referenceElDocumentPos:jt,contentElViewportPos:Pt,contentElDocumentPos:Ot,scrollContainer:it}),Rt=Bt.align,Vt=Bt.justify,Mt=Bt.positionCSS,Ft=Mt.transform,zt=x(Mt,dt),Lt=a(lt||(lt=S(["\n opacity: 1;\n position: ",";\n pointer-events: initial;\n "])),z?"":"absolute"),Wt=z?b:o,kt=z?rt?{container:rt}:{className:null!=L?L:void 0}:{};return Nt=null==B?null:"function"==typeof B?B({align:Rt,justify:Vt,referenceElPos:jt}):B,t.createElement(f,{nodeRef:at,in:s,timeout:150,mountOnEnter:!0,unmountOnExit:!0,appear:!0,onEntered:function(){return nt(!0)},onExit:function(){return nt(!1)}},(function(e){var n;return t.createElement(t.Fragment,null,t.createElement("span",{ref:G,className:a(st||(st=S(["\n display: none;\n "])))}),t.createElement(Wt,kt,t.createElement("div",C({},Z,{className:c(gt,a(zt),(n={},O(n,a({transform:Ft}),"entering"===e||"exiting"===e),O(n,Lt,"entered"===e),O(n,a(ut||(ut=S(["\n z-index: ",";\n "])),V),"number"==typeof V),n),R,O({},a(ft||(ft=S(["\n transition-delay: 0ms;\n "]))),"exiting"===e))}),t.createElement("div",{ref:Q},Nt))))}))}mt.displayName="Popover",mt.propTypes={children:p.oneOfType([p.node,p.func]),active:p.bool,className:p.string,align:p.oneOf(Object.values(k)),justify:p.oneOf(Object.values(A)),refEl:p.shape({current:"undefined"!=typeof window?p.instanceOf(Element):p.any}),usePortal:p.bool,portalClassName:p.string,spacing:p.number,adjustOnMutation:p.bool};var vt,yt,wt,bt,Et,Pt,jt,Ot,Ct,xt,St=["refButtonPosition","buttonText"],Tt=["refButtonPosition","buttonText"],Dt=a(vt||(vt=S(["\n border: 1px solid ",";\n text-align: center;\n padding: 20px;\n max-height: 100%;\n overflow: hidden;\n // Reset these properties since they'll be inherited\n // from the container element when not using a portal.\n font-size: initial;\n color: initial;\n background-color: initial;\n"])),u.gray.light1),Ht=a(yt||(yt=S(["\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"]))),Nt=a(wt||(wt=S(["\n width: 500px;\n height: 90vh;\n background-color: ",";\n overflow: scroll;\n position: relative;\n"])),u.gray.light2),Bt=a(bt||(bt=S(["\n position: relative;\n height: 130vh;\n display: flex;\n align-items: center;\n justify-content: center;\n"]))),Rt=a(Et||(Et=S(["\n position: relative;\n"]))),Vt={centered:a(Pt||(Pt=S(["\n position: relative;\n "]))),top:a(jt||(jt=S(["\n top: 0;\n position: absolute;\n "]))),right:a(Ot||(Ot=S(["\n right: 0;\n position: absolute;\n "]))),bottom:a(Ct||(Ct=S(["\n bottom: 0;\n position: absolute;\n "]))),left:a(xt||(xt=S(["\n left: 0;\n position: absolute;\n "])))},Mt={title:"Components/Popover",component:mt,args:{align:k.Top,justify:A.Start,spacing:10,adjustOnMutation:!1,buttonText:"Button Text"},argTypes:{buttonText:{type:"string",description:"Storybook only prop. Used to change the reference button text"},refButtonPosition:{options:["centered","top","right","bottom","left"],control:{type:"select"},description:"Storybook only prop. Used to change position of the reference button",defaultValue:"centered"}},parameters:{default:"Basic",controls:{exclude:[].concat(D(s),["children","active","refEl","portalClassName","refButtonPosition","usePortal"])}}},Ft=function(n){var o=n.refButtonPosition,r=n.buttonText,a=x(n,St),l=T(e(!1),2),s=l[0],u=l[1],f=Vt[o];return t.createElement("div",{className:Ht},t.createElement(i,{className:c(Rt,f),onClick:function(){return u((function(t){return!t}))}},r,t.createElement(mt,C({},a,{active:s}),t.createElement("div",{className:Dt},"Popover content"))))},zt=function(n){var o=n.refButtonPosition,a=n.buttonText,c=x(n,Tt),l=T(e(!1),2),s=l[0],u=l[1],f=r(null),p=Vt[o];return t.createElement("div",{className:Nt},t.createElement("div",{className:Bt,ref:f},t.createElement(i,{onClick:function(){return u((function(t){return!t}))},className:p},a,t.createElement(mt,C({},c,{active:s,portalContainer:f.current,scrollContainer:f.current}),t.createElement("div",{className:Dt},"Popover content")))))};zt.args={usePortal:!0},zt.argTypes={usePortal:{control:"none"},portalClassName:{control:"none"},refEl:{control:"none"},className:{control:"none"},active:{control:"none"}};export{Ft as Basic,zt as ScrollableContainer,Mt as default}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4896
425873
2