Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@leafygreen-ui/popover

Package Overview
Dependencies
Maintainers
3
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafygreen-ui/popover - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

dist/Align.d.ts

2

dist/index.js

@@ -1,2 +0,2 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("react"),require("prop-types"),require("@leafygreen-ui/portal"),require("@leafygreen-ui/lib"));else if("function"==typeof define&&define.amd)define(["react","prop-types","@leafygreen-ui/portal","@leafygreen-ui/lib"],e);else{var n="object"==typeof exports?e(require("react"),require("prop-types"),require("@leafygreen-ui/portal"),require("@leafygreen-ui/lib")):e(t.react,t["prop-types"],t["@leafygreen-ui/portal"],t["@leafygreen-ui/lib"]);for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(window,function(t,e,n,r){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.Justify=e.Align=void 0;var r=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,n):{};r.get||r.set?Object.defineProperty(e,n,r):e[n]=t[n]}return e.default=t,e}(n(1)),i=l(n(6)),o=l(n(7)),a=n(8),c=n(9),u=n(10);function l(t){return t&&t.__esModule?t:{default:t}}function f(){return(f=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}).apply(this,arguments)}function s(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==c.return||c.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function p(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var d,g,h=a.emotion.css,v=a.emotion.cx,b=h("transition:transform 150ms ease-in-out,opacity 150ms ease-in-out;position:absolute;pointer-events:none;opacity:0;"),y={attributes:!0,characterData:!0,childList:!0,subtree:!0};function m(t){var e=t.children,n=t.active,i=t.className,a=t.usePortal,l=t.spacing,d=t.align,g=t.justify,m=t.refEl,w=t.adjustOnMutation,j=p(t,["children","active","className","usePortal","spacing","align","justify","refEl","adjustOnMutation"]),O=s((0,u.useElementNode)(),2),P=O[0],E=O[1],x=s((0,u.useElementNode)(),2),A=x[0],T=x[1],M=null;if(m&&m.current)M=m.current;else if(P){var S=P.parentNode;S&&S instanceof HTMLElement&&(M=S)}var H,_,L,k=(0,u.useViewportSize)(),R=(0,u.useMutationObserver)(M,y,function(){return Date.now()},w),B=(0,u.useMutationObserver)(A,y,function(){return Date.now()},w),C=(0,r.useMemo)(function(){return(0,c.getElementPosition)(M)},[M,k,R]),W=(0,r.useMemo)(function(){return(0,c.getElementPosition)(A)},[A,k,B]),z=h((0,c.calculatePosition)({useRelativePositioning:!a,spacing:l,align:d,justify:g,referenceElPos:C,contentElPos:W})),N=h("transform:translate3d(0,0,0) scale(1);opacity:1;position:",a?"":"absolute",";pointer-events:initial;"),J=a?o.default:r.Fragment;return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{ref:E,className:h("display:none;")}),r.default.createElement(J,null,r.default.createElement("div",f({},j,{ref:T,className:v(b,z,(H={},_=N,L=n,_ in H?Object.defineProperty(H,_,{value:L,enumerable:!0,configurable:!0,writable:!0}):H[_]=L,H),i)}),e)))}e.Align=d,function(t){t.Top="top",t.Bottom="bottom",t.Left="left",t.Right="right"}(d||(e.Align=d={})),e.Justify=g,function(t){t.Start="start",t.Middle="middle",t.End="end"}(g||(e.Justify=g={})),m.displayName="Popover",m.propTypes={children:i.default.node,active:i.default.bool,className:i.default.string,align:i.default.oneOf(Object.values(d)),justify:i.default.oneOf(Object.values(g)),refEl:i.default.shape({current:i.default.instanceOf(Element)}),usePortal:i.default.bool,spacing:i.default.number,adjustOnMutation:i.default.bool},m.defaultProps={children:void 0,align:d.Bottom,justify:g.Start,active:!1,usePortal:!0,spacing:10,adjustOnMutation:!1};var w=m;e.default=w},function(e,n){e.exports=t},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,n){var r=n(13),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e,n){var r=n(3).Symbol;t.exports=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Align",{enumerable:!0,get:function(){return r.Align}}),Object.defineProperty(e,"Justify",{enumerable:!0,get:function(){return r.Justify}}),e.default=void 0;var r=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,n):{};r.get||r.set?Object.defineProperty(e,n,r):e[n]=t[n]}return e.default=t,e}(n(0));var i=r.default;e.default=i},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e){t.exports=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.calculatePosition=function(t){var e=t.useRelativePositioning,n=t.spacing,s=t.align,p=t.justify,d=t.referenceElPos,g=void 0===d?a:d,h=t.contentElPos,v=void 0===h?a:h,b=t.windowHeight,y=void 0===b?window.innerHeight:b,m=t.windowWidth,w={windowWidth:void 0===m?window.innerWidth:m,windowHeight:y,referenceElPos:g,contentElPos:v,spacing:n},j=function(t,e){var n=e.spacing,i=e.contentElPos,o=e.windowWidth,a=e.windowHeight,s=e.referenceElPos;return{top:[r.Align.Top,r.Align.Bottom],bottom:[r.Align.Bottom,r.Align.Top],left:[r.Align.Left,r.Align.Right],right:[r.Align.Right,r.Align.Left]}[t].find(function(t){if([r.Align.Top,r.Align.Bottom].includes(t)){var e=c({alignment:t,contentElPos:i,referenceElPos:s,spacing:n});return f({top:e,windowHeight:a,contentHeight:i.height})}if([r.Align.Left,r.Align.Right].includes(t)){var p=u({alignment:t,contentElPos:i,referenceElPos:s,spacing:n});return l({left:p,windowWidth:o,contentWidth:i.width})}return!1})||t}(s,w),O=function(t,e,n){var a,s=n.spacing,p=n.contentElPos,d=n.windowWidth,g=n.windowHeight,h=n.referenceElPos;switch(e){case r.Align.Left:case r.Align.Right:var v;i(v={},r.Justify.Start,[o.Top,o.Bottom,o.CenterVertical]),i(v,r.Justify.Middle,[o.CenterVertical,o.Bottom,o.Top]),i(v,r.Justify.End,[o.Bottom,o.Top,o.CenterVertical]),a=v;break;case r.Align.Top:case r.Align.Bottom:default:var b;i(b={},r.Justify.Start,[o.Left,o.Right,o.CenterHorizontal]),i(b,r.Justify.Middle,[o.CenterHorizontal,o.Right,o.Left]),i(b,r.Justify.End,[o.Right,o.Left,o.CenterHorizontal]),a=b}return a[t].find(function(t){if([o.Top,o.Bottom,o.CenterVertical].includes(t)){var e=c({justification:t,contentElPos:p,referenceElPos:h,spacing:s});return f({top:e,windowHeight:g,contentHeight:p.height})}if([o.Left,o.Right,o.CenterHorizontal].includes(t)){var n=u({justification:t,contentElPos:p,referenceElPos:h,spacing:s});return l({left:n,windowWidth:d,contentWidth:p.width})}return!1})||a[t][0]}(p,j,w),P=function(t){var e=t.alignment,n=t.justification,i="",a="";switch(e){case r.Align.Left:i="right";break;case r.Align.Right:i="left";break;case r.Align.Bottom:a="top";break;case r.Align.Top:a="bottom"}switch(n){case o.Left:i="left";break;case o.Right:i="right";break;case o.Bottom:a="bottom";break;case o.Top:a="top";break;case o.CenterHorizontal:i="center";break;case o.CenterVertical:a="center"}return"".concat(i," ").concat(a)}({alignment:j,justification:O}),E=function(t,e){switch(t){case r.Align.Top:return"translate3d(0, ".concat(e,"px, 0) scale(").concat(.8,")");case r.Align.Bottom:return"translate3d(0, -".concat(e,"px, 0) scale(").concat(.8,")");case r.Align.Left:return"translate3d(".concat(e,"px, 0, 0) scale(").concat(.8,")");case r.Align.Right:return"translate3d(-".concat(e,"px, 0, 0) scale(").concat(.8,")")}}(j,n);if(e)return function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){i(t,e,n[e])})}return t}({},function(t){var e=t.alignment,n=t.justification,i=t.referenceElPos,a=t.contentElPos,c=t.spacing,u={};switch(e){case r.Align.Top:u.bottom="calc(100% + ".concat(c,"px)");break;case r.Align.Bottom:u.top="calc(100% + ".concat(c,"px)");break;case r.Align.Left:u.right="calc(100% + ".concat(c,"px)");break;case r.Align.Right:u.left="calc(100% + ".concat(c,"px)")}switch(n){case o.Top:u.top=0;break;case o.Bottom:u.bottom=0;break;case o.Left:u.left=0;break;case o.Right:u.right=0;break;case o.CenterHorizontal:u.left="".concat(i.width/2-a.width/2,"px");break;case o.CenterVertical:u.top="".concat(i.height/2-a.height/2,"px")}return u}({alignment:j,justification:O,referenceElPos:g,contentElPos:v,spacing:n}),{transformOrigin:P,transform:E});return{top:c({alignment:j,justification:O,contentElPos:v,referenceElPos:g,spacing:n}),left:u({alignment:j,justification:O,contentElPos:v,referenceElPos:g,spacing:n}),transformOrigin:P,transform:E}},e.getElementPosition=function(t){if(!t)return a;var e=t.getBoundingClientRect(),n=e.top,r=e.bottom,i=e.left,o=e.right,c=t.offsetHeight,u=t.offsetWidth;return{top:n,bottom:r,left:i,right:o,height:c,width:u}};var r=n(0);function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o,a={top:0,bottom:0,left:0,right:0,height:0,width:0};function c(t){var e=t.alignment,n=t.justification,i=t.contentElPos,a=t.referenceElPos,c=t.spacing;switch(n){case o.Top:return a.top;case o.Bottom:return a.top+a.height-i.height;case o.CenterVertical:return a.top+a.height/2-i.height/2}switch(e){case r.Align.Top:return a.top-i.height-c;case r.Align.Bottom:default:return a.top+a.height+c}}function u(t){var e=t.alignment,n=t.justification,i=t.contentElPos,a=t.referenceElPos,c=t.spacing;switch(e){case r.Align.Left:return a.left-i.width-c;case r.Align.Right:return a.left+a.width+c}switch(n){case o.Right:return a.left+a.width-i.width;case o.CenterHorizontal:return a.left+a.width/2-i.width/2;case o.Left:default:return a.left}}function l(t){var e=t.left,n=t.windowWidth,r=t.contentWidth;return e>=0&&!(e+r>n)}function f(t){var e=t.top,n=t.windowHeight,r=t.contentHeight;return e>=0&&!(e+r>n)}!function(t){t.Top="top",t.Bottom="bottom",t.Left="left",t.Right="right",t.CenterVertical="center-vertical",t.CenterHorizontal="center-horizontal"}(o||(o={}))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useViewportSize=function(){var t=a((0,i.useState)(c),2),e=t[0],n=t[1];return(0,i.useEffect)(function(){var t=(0,o.default)(function(){return n(c())},100);return window.addEventListener("resize",t),function(){return window.removeEventListener("resize",t)}},[]),e},e.useMutationObserver=function(t,e,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=a((0,i.useState)(),2),c=o[0],u=o[1];return(0,i.useEffect)(function(){if(r){var i=new MutationObserver(function(){u(n.apply(void 0,arguments))});return t&&i.observe(t,e),function(){return i.disconnect()}}},[t,e,n,r]),c},e.useElementNode=function(){var t=a((0,i.useState)(null),2),e=t[0],n=t[1],r=(0,i.useCallback)(function(t){t&&n(t)},[]);return[e,r]};var r,i=n(1),o=(r=n(11))&&r.__esModule?r:{default:r};function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==c.return||c.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function c(){return{width:window.innerWidth,height:window.innerHeight}}},function(t,e,n){var r=n(2),i=n(12),o=n(15),a="Expected a function",c=Math.max,u=Math.min;t.exports=function(t,e,n){var l,f,s,p,d,g,h=0,v=!1,b=!1,y=!0;if("function"!=typeof t)throw new TypeError(a);function m(e){var n=l,r=f;return l=f=void 0,h=e,p=t.apply(r,n)}function w(t){var n=t-g;return void 0===g||n>=e||n<0||b&&t-h>=s}function j(){var t=i();if(w(t))return O(t);d=setTimeout(j,function(t){var n=e-(t-g);return b?u(n,s-(t-h)):n}(t))}function O(t){return d=void 0,y&&l?m(t):(l=f=void 0,p)}function P(){var t=i(),n=w(t);if(l=arguments,f=this,g=t,n){if(void 0===d)return function(t){return h=t,d=setTimeout(j,e),v?m(t):p}(g);if(b)return d=setTimeout(j,e),m(g)}return void 0===d&&(d=setTimeout(j,e)),p}return e=o(e)||0,r(n)&&(v=!!n.leading,s=(b="maxWait"in n)?c(o(n.maxWait)||0,e):s,y="trailing"in n?!!n.trailing:y),P.cancel=function(){void 0!==d&&clearTimeout(d),h=0,l=g=f=d=void 0},P.flush=function(){return void 0===d?p:O(i())},P}},function(t,e,n){var r=n(3);t.exports=function(){return r.Date.now()}},function(t,e,n){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(this,n(14))},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(2),i=n(16),o=NaN,a=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,l=/^0o[0-7]+$/i,f=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(i(t))return o;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(a,"");var n=u.test(t);return n||l.test(t)?f(t.slice(2),n?2:8):c.test(t)?o:+t}},function(t,e,n){var r=n(17),i=n(20),o="[object Symbol]";t.exports=function(t){return"symbol"==typeof t||i(t)&&r(t)==o}},function(t,e,n){var r=n(4),i=n(18),o=n(19),a="[object Null]",c="[object Undefined]",u=r?r.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?c:a:u&&u in Object(t)?i(t):o(t)}},function(t,e,n){var r=n(4),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,c=r?r.toStringTag:void 0;t.exports=function(t){var e=o.call(t,c),n=t[c];try{t[c]=void 0;var r=!0}catch(t){}var i=a.call(t);return r&&(e?t[c]=n:delete t[c]),i}},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}}])});
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"),require("@leafygreen-ui/portal"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks"));else if("function"==typeof define&&define.amd)define(["react","prop-types","@leafygreen-ui/portal","@leafygreen-ui/emotion","@leafygreen-ui/hooks"],t);else{var n="object"==typeof exports?t(require("react"),require("prop-types"),require("@leafygreen-ui/portal"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/hooks")):t(e.react,e["prop-types"],e["@leafygreen-ui/portal"],e["@leafygreen-ui/emotion"],e["@leafygreen-ui/hooks"]);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(e,t,n,r,o){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={Top:"top",Bottom:"bottom",Left:"left",Right:"right"};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={Start:"start",Middle:"middle",End:"end"};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PopoverProps",{enumerable:!0,get:function(){return r.PopoverProps}}),Object.defineProperty(t,"Align",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"Justify",{enumerable:!0,get:function(){return i.default}}),t.default=void 0;var r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,n):{};r.get||r.set?Object.defineProperty(t,n,r):t[n]=e[n]}return t.default=e,t}(n(3)),o=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}var u=r.default;t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,n):{};r.get||r.set?Object.defineProperty(t,n,r):t[n]=e[n]}return t.default=e,t}(n(4)),o=s(n(5)),i=s(n(6)),a=n(7),u=n(8),l=s(n(0)),c=s(n(1)),f=n(9);function s(e){return e&&e.__esModule?e:{default:e}}function d(){return(d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function g(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var h=(0,a.css)("transition:transform 150ms ease-in-out,opacity 150ms ease-in-out;position:absolute;pointer-events:none;opacity:0;"),b={attributes:!0,characterData:!0,childList:!0,subtree:!0};function v(e){var t=e.active,n=void 0!==t&&t,o=e.usePortal,s=void 0===o||o,v=e.spacing,m=void 0===v?10:v,y=e.align,P=void 0===y?l.default.Bottom:y,w=e.justify,O=void 0===w?c.default.Start:w,j=e.adjustOnMutation,E=void 0!==j&&j,x=e.children,M=e.className,_=e.refEl,k=g(e,["active","usePortal","spacing","align","justify","adjustOnMutation","children","className","refEl"]),T=p((0,u.useElementNode)(),2),H=T[0],B=T[1],R=p((0,u.useElementNode)(),2),L=R[0],C=R[1],S=null;if(_&&_.current)S=_.current;else if(H){var W=H.parentNode;W&&W instanceof HTMLElement&&(S=W)}var q,z,N,V=(0,u.useViewportSize)(),D=(0,u.useMutationObserver)(S,b,function(){return Date.now()},E),A=(0,u.useMutationObserver)(L,b,function(){return Date.now()},E),F=(0,r.useMemo)(function(){return(0,f.getElementPosition)(S)},[S,V,D]),I=(0,r.useMemo)(function(){return(0,f.getElementPosition)(L)},[L,V,A]),J=(0,a.css)((0,f.calculatePosition)({useRelativePositioning:!s,spacing:m,align:P,justify:O,referenceElPos:F,contentElPos:I})),G=(0,a.css)("transform:translate3d(0,0,0) scale(1);opacity:1;position:",s?"":"absolute",";pointer-events:initial;"),K=s?i.default:r.Fragment;return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{ref:B,className:(0,a.css)("display:none;")}),r.default.createElement(K,null,r.default.createElement("div",d({},k,{ref:C,className:(0,a.cx)(h,J,(q={},z=G,N=n,z in q?Object.defineProperty(q,z,{value:N,enumerable:!0,configurable:!0,writable:!0}):q[z]=N,q),M)}),x)))}v.displayName="Popover",v.propTypes={children:o.default.node,active:o.default.bool,className:o.default.string,align:o.default.oneOf(Object.values(l.default)),justify:o.default.oneOf(Object.values(c.default)),refEl:o.default.shape({current:o.default.instanceOf(Element)}),usePortal:o.default.bool,spacing:o.default.number,adjustOnMutation:o.default.bool},v.defaultProps={children:void 0,align:l.default.Bottom,justify:c.default.Start,active:!1,usePortal:!0,spacing:10,adjustOnMutation:!1};var m=v;t.default=m},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t){e.exports=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calculatePosition=function(e){var t=e.useRelativePositioning,n=e.spacing,i=e.align,p=e.justify,g=e.referenceElPos,h=void 0===g?u:g,b=e.contentElPos,v=void 0===b?u:b,m=e.windowHeight,y=void 0===m?window.innerHeight:m,P=e.windowWidth,w={windowWidth:void 0===P?window.innerWidth:P,windowHeight:y,referenceElPos:h,contentElPos:v,spacing:n},O=function(e,t){var n=t.spacing,o=t.contentElPos,i=t.windowWidth,a=t.windowHeight,u=t.referenceElPos;return{top:[r.default.Top,r.default.Bottom],bottom:[r.default.Bottom,r.default.Top],left:[r.default.Left,r.default.Right],right:[r.default.Right,r.default.Left]}[e].find(function(e){if([r.default.Top,r.default.Bottom].includes(e)){var t=c({alignment:e,contentElPos:o,referenceElPos:u,spacing:n});return d({top:t,windowHeight:a,contentHeight:o.height})}if([r.default.Left,r.default.Right].includes(e)){var l=f({alignment:e,contentElPos:o,referenceElPos:u,spacing:n});return s({left:l,windowWidth:i,contentWidth:o.width})}return!1})||e}(i,w),j=function(e,t,n){var i,u=n.spacing,p=n.contentElPos,g=n.windowWidth,h=n.windowHeight,b=n.referenceElPos;switch(t){case r.default.Left:case r.default.Right:var v;a(v={},o.default.Start,[l.Top,l.Bottom,l.CenterVertical]),a(v,o.default.Middle,[l.CenterVertical,l.Bottom,l.Top]),a(v,o.default.End,[l.Bottom,l.Top,l.CenterVertical]),i=v;break;case r.default.Top:case r.default.Bottom:default:var m;a(m={},o.default.Start,[l.Left,l.Right,l.CenterHorizontal]),a(m,o.default.Middle,[l.CenterHorizontal,l.Right,l.Left]),a(m,o.default.End,[l.Right,l.Left,l.CenterHorizontal]),i=m}return i[e].find(function(e){if([l.Top,l.Bottom,l.CenterVertical].includes(e)){var t=c({justification:e,contentElPos:p,referenceElPos:b,spacing:u});return d({top:t,windowHeight:h,contentHeight:p.height})}if([l.Left,l.Right,l.CenterHorizontal].includes(e)){var n=f({justification:e,contentElPos:p,referenceElPos:b,spacing:u});return s({left:n,windowWidth:g,contentWidth:p.width})}return!1})||i[e][0]}(p,O,w),E=function(e){var t=e.alignment,n=e.justification,o="",i="";switch(t){case r.default.Left:o="right";break;case r.default.Right:o="left";break;case r.default.Bottom:i="top";break;case r.default.Top:i="bottom"}switch(n){case l.Left:o="left";break;case l.Right:o="right";break;case l.Bottom:i="bottom";break;case l.Top:i="top";break;case l.CenterHorizontal:o="center";break;case l.CenterVertical:i="center"}return"".concat(o," ").concat(i)}({alignment:O,justification:j}),x=function(e,t){switch(e){case r.default.Top:return"translate3d(0, ".concat(t,"px, 0) scale(").concat(.8,")");case r.default.Bottom:return"translate3d(0, -".concat(t,"px, 0) scale(").concat(.8,")");case r.default.Left:return"translate3d(".concat(t,"px, 0, 0) scale(").concat(.8,")");case r.default.Right:return"translate3d(-".concat(t,"px, 0, 0) scale(").concat(.8,")")}}(O,n);if(t)return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){a(e,t,n[t])})}return e}({},function(e){var t=e.alignment,n=e.justification,o=e.referenceElPos,i=e.contentElPos,a=e.spacing,u={};switch(t){case r.default.Top:u.bottom="calc(100% + ".concat(a,"px)");break;case r.default.Bottom:u.top="calc(100% + ".concat(a,"px)");break;case r.default.Left:u.right="calc(100% + ".concat(a,"px)");break;case r.default.Right:u.left="calc(100% + ".concat(a,"px)")}switch(n){case l.Top:u.top=0;break;case l.Bottom:u.bottom=0;break;case l.Left:u.left=0;break;case l.Right:u.right=0;break;case l.CenterHorizontal:u.left="".concat(o.width/2-i.width/2,"px");break;case l.CenterVertical:u.top="".concat(o.height/2-i.height/2,"px")}return u}({alignment:O,justification:j,referenceElPos:h,contentElPos:v,spacing:n}),{transformOrigin:E,transform:x});return{top:c({alignment:O,justification:j,contentElPos:v,referenceElPos:h,spacing:n}),left:f({alignment:O,justification:j,contentElPos:v,referenceElPos:h,spacing:n}),transformOrigin:E,transform:x}},t.getElementPosition=function(e){if(!e)return u;var t=e.getBoundingClientRect(),n=t.top,r=t.bottom,o=t.left,i=t.right,a=e.offsetHeight,l=e.offsetWidth;return{top:n,bottom:r,left:o,right:i,height:a,width:l}};var r=i(n(0)),o=i(n(1));function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u={top:0,bottom:0,left:0,right:0,height:0,width:0};var l={Top:"top",Bottom:"bottom",Left:"left",Right:"right",CenterVertical:"center-vertical",CenterHorizontal:"center-horizontal"};function c(e){var t=e.alignment,n=e.justification,o=e.contentElPos,i=e.referenceElPos,a=e.spacing;switch(n){case l.Top:return i.top;case l.Bottom:return i.top+i.height-o.height;case l.CenterVertical:return i.top+i.height/2-o.height/2}switch(t){case r.default.Top:return i.top-o.height-a;case r.default.Bottom:default:return i.top+i.height+a}}function f(e){var t=e.alignment,n=e.justification,o=e.contentElPos,i=e.referenceElPos,a=e.spacing;switch(t){case r.default.Left:return i.left-o.width-a;case r.default.Right:return i.left+i.width+a}switch(n){case l.Right:return i.left+i.width-o.width;case l.CenterHorizontal:return i.left+i.width/2-o.width/2;case l.Left:default:return i.left}}function s(e){var t=e.left,n=e.windowWidth,r=e.contentWidth;return t>=0&&!(t+r>n)}function d(e){var t=e.top,n=e.windowHeight,r=e.contentHeight;return t>=0&&!(t+r>n)}}])});
//# sourceMappingURL=index.js.map
{
"name": "@leafygreen-ui/popover",
"version": "1.0.1",
"version": "1.1.0",
"description": "LeafyGreen UI Kit Popover",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "../../node_modules/.bin/webpack --config ../../webpack.config.js"
"build": "../../node_modules/.bin/webpack --config ../../webpack.config.js",
"ts:emit": "tsc --project ./tsconfig.json"
},

@@ -14,8 +16,9 @@ "license": "Apache-2.0",

"dependencies": {
"@leafygreen-ui/lib": "^2.1.7",
"@leafygreen-ui/portal": "^1.0.5",
"@leafygreen-ui/theme": "^1.1.7",
"@leafygreen-ui/hooks": "^1.0.0",
"@leafygreen-ui/lib": "^3.0.0",
"@leafygreen-ui/portal": "^1.1.0",
"@leafygreen-ui/theme": "^1.2.0",
"lodash": "^4.17.11"
},
"gitHead": "06423f1e61a63751332ed421a70ca2921abd5a1a"
"gitHead": "e237f95550d3c42d14455b1ab94c7dade22e0691"
}

@@ -6,2 +6,4 @@ # Popover

```js
import Popover from '@leafygreen-ui/popover';
<button

@@ -21,3 +23,3 @@ className={containerStyle}

</Popover>
</button>
</button>;
```

@@ -24,0 +26,0 @@

import Popover from './Popover';
export { Align, Justify } from './Popover';
import Align from './Align';
import Justify from './Justify';
export { PopoverProps } from './Popover';
export default Popover;
export { Align, Justify };

@@ -1,2 +0,3 @@

import { Align, Justify } from './Popover';
import Align from './Align';
import Justify from './Justify';
import { calculatePosition, getElementPosition } from './positionUtils';

@@ -3,0 +4,0 @@

@@ -1,2 +0,3 @@

import { Align, Justify } from './Popover';
import Align from './Align';
import Justify from './Justify';

@@ -124,11 +125,13 @@ interface ElementPosition {

// So both Justify and Justification are needed, where the same is not true for Alignment.
enum Justification {
Top = 'top',
Bottom = 'bottom',
Left = 'left',
Right = 'right',
CenterVertical = 'center-vertical',
CenterHorizontal = 'center-horizontal',
}
const Justification = {
Top: 'top',
Bottom: 'bottom',
Left: 'left',
Right: 'right',
CenterVertical: 'center-vertical',
CenterHorizontal: 'center-horizontal',
} as const;
type Justification = typeof Justification[keyof typeof Justification];
interface TransformOriginArgs {

@@ -414,3 +417,3 @@ alignment: Align;

if ([Align.Top, Align.Bottom].includes(alignment)) {
if (([Align.Top, Align.Bottom] as Array<Align>).includes(alignment)) {
const top = calcTop({

@@ -429,3 +432,3 @@ alignment,

if ([Align.Left, Align.Right].includes(alignment)) {
if (([Align.Left, Align.Right] as Array<Align>).includes(alignment)) {
const left = calcLeft({

@@ -522,7 +525,7 @@ alignment,

if (
[
([
Justification.Top,
Justification.Bottom,
Justification.CenterVertical,
].includes(justification)
] as Array<Justification>).includes(justification)
) {

@@ -544,7 +547,7 @@ const top = calcTop({

if (
[
([
Justification.Left,
Justification.Right,
Justification.CenterHorizontal,
].includes(justification)
] as Array<Justification>).includes(justification)
) {

@@ -551,0 +554,0 @@ const left = calcLeft({

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc