@leafygreen-ui/tooltip
Advanced tools
Comparing version 6.0.0 to 6.0.1
# @leafygreen-ui/tooltip | ||
## 6.0.1 | ||
### Patch Changes | ||
- dac3f38b: Fixes a publishing error that prevented UMD modules from being distributed | ||
- Updated dependencies [dac3f38b] | ||
- Updated dependencies [059ef833] | ||
- @leafygreen-ui/hooks@5.0.1 | ||
- @leafygreen-ui/lib@6.0.1 | ||
- @leafygreen-ui/palette@3.0.1 | ||
- @leafygreen-ui/popover@7.0.1 | ||
- @leafygreen-ui/tokens@0.5.0 | ||
## 6.0.0 | ||
@@ -4,0 +17,0 @@ |
@@ -1,2 +0,2 @@ | ||
import t,{useState as n,useRef as r,useMemo as e}from"react";import o from"prop-types";import i,{Justify as a,Align as c}from"@leafygreen-ui/popover";export{Justify}from"@leafygreen-ui/popover";import{useEscapeKey as l,useEventListener as u}from"@leafygreen-ui/hooks";import{css as p,cx as f}from"@leafygreen-ui/emotion";import{uiColors as s}from"@leafygreen-ui/palette";import{fontFamilies as d}from"@leafygreen-ui/tokens";import{IdAllocator as g}from"@leafygreen-ui/lib";import{useBaseFontSize as b}from"@leafygreen-ui/leafygreen-provider";import{transparentize as m}from"polished";import h from"lodash/debounce";import y from"lodash/clamp";function v(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function x(){return(x=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t}).apply(this,arguments)}function O(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),r.push.apply(r,e)}return r}function k(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?O(Object(r),!0).forEach((function(n){v(t,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))}))}return t}function j(t,n){if(null==t)return{};var r,e,o=function(t,n){if(null==t)return{};var r,e,o={},i=Object.keys(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||(o[r]=t[r]);return o}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function w(t,n){return n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}}))}function P(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],e=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(e=(a=c.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==c.return||c.return()}finally{if(o)throw i}}return r}(t,n)||function(t,n){if(!t)return;if("string"==typeof t)return E(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(t,n)}(t,n)||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 E(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function C(){var t=w(["\n min-width: ","px;\n transform: ",";\n "]);return C=function(){return t},t}function N(){var t=w(["\n ",";\n position: absolute;\n transform: rotate(45deg);\n width: 8px;\n height: 8px;\n margin: auto;\n "]);return N=function(){return t},t}function S(){var t=w(["\n position: absolute;\n width: ","px;\n height: ","px;\n overflow: hidden;\n margin: auto;\n ",";\n "]);return S=function(){return t},t}var M;function A(){var t=w(["\n background-color: ",";\n border: 1px solid ",";\n box-shadow: 0px 2px 4px ",";\n "]);return A=function(){return t},t}function T(){var t=w(["\n color: ",";\n "]);return T=function(){return t},t}function D(){var t=w(["\n background-color: ",";\n color: ",";\n border: 1px solid ",";\n "]);return D=function(){return t},t}function z(){var t=w(["\n background-color: ",";\n box-shadow: 0px 2px 4px ",";\n "]);return z=function(){return t},t}function F(){var t=w(["\n color: ",";\n "]);return F=function(){return t},t}function I(){var t=w(["\n background-color: ",";\n color: ",";\n "]);return I=function(){return t},t}function B(){var t=w(["\n position: relative;\n"]);return B=function(){return t},t}function H(){var t=w(["\n padding: 14px 16px;\n border-radius: 3px;\n box-shadow: 0px 2px 4px ",";\n cursor: default;\n"]);return H=function(){return t},t}function L(){var t=w(["\n font-size: 16px;\n line-height: 24px;\n letter-spacing: 0px;\n"]);return L=function(){return t},t}function R(){var t=w(["\n font-size: 14px;\n line-height: 20px;\n letter-spacing: 0px;\n"]);return R=function(){return t},t}function X(){var t=w(["\n margin: unset;\n font-family: ",";\n color: ",";\n font-weight: 400;\n"]);return X=function(){return t},t}var Y=p(X(),d.default,s.gray.dark3),J=p(R()),U=p(L()),$={Hover:"hover",Click:"click"},q="light",G="dark",K={Top:c.Top,Bottom:c.Bottom,Left:c.Left,Right:c.Right},Q=p(H(),m(.85,s.black)),V=p(B()),W=(v(M={},G,{tooltip:p(I(),s.gray.dark3,s.gray.light1),children:p(F(),s.gray.light1),notch:p(z(),s.gray.dark3,m(.85,s.black))}),v(M,q,{tooltip:p(D(),s.gray.light3,s.gray.dark2,s.gray.light2),children:p(T(),s.gray.dark2),notch:p(A(),s.gray.light3,s.gray.light2,m(.85,s.black))}),M),Z=g.create("tooltip"),_=function(t){t.preventDefault(),t.stopPropagation()};function tt(o){var c,s=o.open,d=o.setOpen,g=o.className,m=o.children,v=o.trigger,O=o.triggerEvent,w=void 0===O?$.Hover:O,E=o.darkMode,M=void 0!==E&&E,A=o.enabled,T=void 0===A||A,D=o.usePortal,z=void 0===D||D,F=o.align,I=void 0===F?"top":F,B=o.justify,H=void 0===B?"start":B,L=o.spacing,R=void 0===L?12:L,X=o.id,K=o.shouldClose,tt=o.portalClassName,nt=j(o,["open","setOpen","className","children","trigger","triggerEvent","darkMode","enabled","usePortal","align","justify","spacing","id","shouldClose","portalClassName"]),rt="boolean"==typeof s,et=P(n(!1),2),ot=et[0],it=et[1],at=b(),ct=rt?s:ot,lt=rt&&d?d:it,ut=r(null),pt=null!=X?X:null===(c=ut.current)||void 0===c?void 0:c.id,ft=e((function(){return null!=pt?pt:Z.generate()}),[pt]),st=function(t,n){return t===$.Hover?{onMouseEnter:h((function(){lt(!0)}),35),onMouseLeave:h(dt,35),onFocus:function(){return lt(!0)},onBlur:dt}:n&&n.onClick?{onClick:function(t){t.target!==ut.current&&(n.onClick(),lt((function(t){return!t})))}}:{onClick:function(t){t.target!==ut.current&<((function(t){return!t}))}}},dt=function(){("function"!=typeof K||K())&<(!1)};l(dt,{enabled:ct});u("click",(function(t){var n=ut&&ut.current;n&&!n.contains(t.target)&&dt()}),{enabled:ct&&"click"===w});var gt=z?{spacing:R,usePortal:z,portalClassName:tt}:{spacing:R,usePortal:z},bt=M?G:q,mt=t.createElement(i,x({key:"tooltip",active:T&&ct,align:I,justify:H,adjustOnMutation:!0,onClick:_},gt),(function(n){var r=function(t,n,r){if(!t||!n||!r)return{notchContainer:"",notch:"",tooltip:""};var e,o,i={},c={},l=10,u=0,f="";switch(t){case"top":case"bottom":switch(l=15,e=r.width/2-7.5,u=y(e,5,l),o=e<=5,i.left="0px",i.right="0px","top"===t?(c.top="100%",i.top="".concat(-4,"px")):(c.bottom="100%",i.bottom="".concat(-4,"px")),n){case a.Start:c.left="".concat(u,"px"),o&&(f="translateX(-".concat(5-e,"px)"));break;case a.Middle:case a.Fit:c.left="0px",c.right="0px";break;case a.End:c.right="".concat(u,"px"),o&&(f="translateX(".concat(5-e,"px)"))}break;case"left":case"right":switch(l=10,e=r.height/2-7.5,u=y(e,5,l),o=e<=5,i.top="0px",i.bottom="0px","left"===t?(i.left="".concat(-4,"px"),c.left="100%"):(i.right="".concat(-4,"px"),c.right="100%"),n){case a.Start:c.top="".concat(u,"px"),o&&(f="translateY(-".concat(5-e,"px)"));break;case a.Middle:case a.Fit:c.top="0px",c.bottom="0px";break;case a.End:c.bottom="".concat(u,"px"),o&&(f="translateY(".concat(5-e,"px)"))}}return{notchContainer:p(S(),15,15,p(c)),notch:p(N(),p(i)),tooltip:p(C(),2*u+15,f)}}(n.align,n.justify,n.referenceElPos),e=r.notchContainer,o=r.notch,i=r.tooltip;return t.createElement("div",x({},nt,{role:"tooltip",id:ft,className:f(Q,i,W[bt].tooltip,g),ref:ut}),t.createElement("div",{className:e},t.createElement("div",{className:f(o,W[bt].notch)})),t.createElement("div",{className:f(Y,16===at?U:J,W[bt].children)},m))}));return v?"function"==typeof v?v(k({},st(w),{className:V,"aria-describedby":ft,children:mt})):t.cloneElement(v,k({},st(w,v.props),{"aria-describedby":ft,children:t.createElement(t.Fragment,null,v.props.children,mt),className:f(V,v.props.className)})):mt}tt.displayName="Tooltip",tt.propTypes={children:o.node,className:o.string,align:o.oneOf(Object.values(K)),justify:o.oneOf(Object.values(a)),trigger:o.oneOfType([o.node,o.func]),triggerEvent:o.oneOf(Object.values($)),darkMode:o.bool,enabled:o.bool,open:o.bool,setOpen:o.func,id:o.string,shouldClose:o.func,usePortal:o.bool,portalClassName:o.string};export default tt;export{K as Align,$ as TriggerEvent}; | ||
import t,{useState as n,useRef as r,useMemo as e}from"react";import o from"prop-types";import i,{Justify as a,Align as c}from"@leafygreen-ui/popover";export{Justify}from"@leafygreen-ui/popover";import{useEscapeKey as l,useEventListener as u}from"@leafygreen-ui/hooks";import{css as p,cx as f}from"@leafygreen-ui/emotion";import{uiColors as s}from"@leafygreen-ui/palette";import{fontFamilies as d}from"@leafygreen-ui/tokens";import{IdAllocator as g}from"@leafygreen-ui/lib";import{useBaseFontSize as b}from"@leafygreen-ui/leafygreen-provider";import{transparentize as m}from"polished";import h from"lodash/debounce";import y from"lodash/clamp";function v(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function x(){return(x=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t}).apply(this,arguments)}function O(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),r.push.apply(r,e)}return r}function k(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?O(Object(r),!0).forEach((function(n){v(t,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))}))}return t}function j(t,n){if(null==t)return{};var r,e,o=function(t,n){if(null==t)return{};var r,e,o={},i=Object.keys(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||(o[r]=t[r]);return o}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(e=0;e<i.length;e++)r=i[e],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function w(t,n){return n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}}))}function P(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],e=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(e=(a=c.next()).done)&&(r.push(a.value),!n||r.length!==n);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==c.return||c.return()}finally{if(o)throw i}}return r}(t,n)||function(t,n){if(!t)return;if("string"==typeof t)return E(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(t,n)}(t,n)||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 E(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function C(){var t=w(["\n min-width: ","px;\n transform: ",";\n "]);return C=function(){return t},t}function N(){var t=w(["\n ",";\n position: absolute;\n transform: rotate(45deg);\n width: 8px;\n height: 8px;\n margin: auto;\n "]);return N=function(){return t},t}function S(){var t=w(["\n position: absolute;\n width: ","px;\n height: ","px;\n overflow: hidden;\n margin: auto;\n ",";\n "]);return S=function(){return t},t}var M;function A(){var t=w(["\n background-color: ",";\n border: 1px solid ",";\n box-shadow: 0px 2px 4px ",";\n "]);return A=function(){return t},t}function T(){var t=w(["\n color: ",";\n "]);return T=function(){return t},t}function D(){var t=w(["\n background-color: ",";\n color: ",";\n border: 1px solid ",";\n "]);return D=function(){return t},t}function z(){var t=w(["\n background-color: ",";\n box-shadow: 0px 2px 4px ",";\n "]);return z=function(){return t},t}function F(){var t=w(["\n color: ",";\n "]);return F=function(){return t},t}function I(){var t=w(["\n background-color: ",";\n color: ",";\n "]);return I=function(){return t},t}function B(){var t=w(["\n position: relative;\n"]);return B=function(){return t},t}function H(){var t=w(["\n padding: 14px 16px;\n border-radius: 3px;\n box-shadow: 0px 2px 4px ",";\n cursor: default;\n"]);return H=function(){return t},t}function L(){var t=w(["\n font-size: 16px;\n line-height: 24px;\n letter-spacing: 0px;\n"]);return L=function(){return t},t}function R(){var t=w(["\n font-size: 14px;\n line-height: 20px;\n letter-spacing: 0px;\n"]);return R=function(){return t},t}function X(){var t=w(["\n margin: unset;\n font-family: ",";\n color: ",";\n font-weight: 400;\n"]);return X=function(){return t},t}var Y=p(X(),d.default,s.gray.dark3),J=p(R()),U=p(L()),$={Hover:"hover",Click:"click"},q="light",G="dark",K={Top:c.Top,Bottom:c.Bottom,Left:c.Left,Right:c.Right},Q=p(H(),m(.85,s.black)),V=p(B()),W=(v(M={},G,{tooltip:p(I(),s.gray.dark3,s.gray.light1),children:p(F(),s.gray.light1),notch:p(z(),s.gray.dark3,m(.85,s.black))}),v(M,q,{tooltip:p(D(),s.gray.light3,s.gray.dark2,s.gray.light2),children:p(T(),s.gray.dark2),notch:p(A(),s.gray.light3,s.gray.light2,m(.85,s.black))}),M),Z=g.create("tooltip"),_=function(t){t.preventDefault(),t.stopPropagation()};function tt(o){var c,s=o.open,d=o.setOpen,g=o.className,m=o.children,v=o.trigger,O=o.triggerEvent,w=void 0===O?$.Hover:O,E=o.darkMode,M=void 0!==E&&E,A=o.enabled,T=void 0===A||A,D=o.usePortal,z=void 0===D||D,F=o.align,I=void 0===F?"top":F,B=o.justify,H=void 0===B?"start":B,L=o.spacing,R=void 0===L?12:L,X=o.id,K=o.shouldClose,tt=o.portalClassName,nt=j(o,["open","setOpen","className","children","trigger","triggerEvent","darkMode","enabled","usePortal","align","justify","spacing","id","shouldClose","portalClassName"]),rt="boolean"==typeof s,et=P(n(!1),2),ot=et[0],it=et[1],at=b(),ct=rt?s:ot,lt=rt&&d?d:it,ut=r(null),pt=null!=X?X:null===(c=ut.current)||void 0===c?void 0:c.id,ft=e((function(){return null!=pt?pt:Z.generate()}),[pt]),st=function(t,n){return t===$.Hover?{onMouseEnter:h((function(){lt(!0)}),35),onMouseLeave:h(dt,35),onFocus:function(){return lt(!0)},onBlur:dt}:n&&n.onClick?{onClick:function(t){t.target!==ut.current&&(n.onClick(),lt((function(t){return!t})))}}:{onClick:function(t){t.target!==ut.current&<((function(t){return!t}))}}},dt=function(){("function"!=typeof K||K())&<(!1)};l(dt,{enabled:ct});u("click",(function(t){var n=ut&&ut.current;n&&!n.contains(t.target)&&dt()}),{enabled:ct&&"click"===w});var gt=z?{spacing:R,usePortal:z,portalClassName:tt}:{spacing:R,usePortal:z},bt=M?G:q,mt=t.createElement(i,x({key:"tooltip",active:T&&ct,align:I,justify:H,adjustOnMutation:!0,onClick:_},gt),(function(n){var r=function(t,n,r){if(!t||!n||!r)return{notchContainer:"",notch:"",tooltip:""};var e,o,i={},c={},l=10,u=0,f="";switch(t){case"top":case"bottom":switch(l=15,e=r.width/2-7.5,u=y(e,5,l),o=e<=5,i.left="0px",i.right="0px","top"===t?(c.top="100%",i.top="".concat(-4,"px")):(c.bottom="100%",i.bottom="".concat(-4,"px")),n){case a.Start:c.left="".concat(u,"px"),o&&(f="translateX(-".concat(5-e,"px)"));break;case a.Middle:case a.Fit:c.left="0px",c.right="0px";break;case a.End:c.right="".concat(u,"px"),o&&(f="translateX(".concat(5-e,"px)"))}break;case"left":case"right":switch(l=10,e=r.height/2-7.5,u=y(e,5,l),o=e<=5,i.top="0px",i.bottom="0px","left"===t?(i.left="".concat(-4,"px"),c.left="100%"):(i.right="".concat(-4,"px"),c.right="100%"),n){case a.Start:c.top="".concat(u,"px"),o&&(f="translateY(-".concat(5-e,"px)"));break;case a.Middle:case a.Fit:c.top="0px",c.bottom="0px";break;case a.End:c.bottom="".concat(u,"px"),o&&(f="translateY(".concat(5-e,"px)"))}}return{notchContainer:p(S(),15,15,p(c)),notch:p(N(),p(i)),tooltip:p(C(),2*u+15,f)}}(n.align,n.justify,n.referenceElPos),e=r.notchContainer,o=r.notch,i=r.tooltip;return t.createElement("div",x({},nt,{role:"tooltip",id:ft,className:f(Q,i,W[bt].tooltip,g),ref:ut}),t.createElement("div",{className:e},t.createElement("div",{className:f(o,W[bt].notch)})),t.createElement("div",{className:f(Y,16===at?U:J,W[bt].children)},m))}));return v?"function"==typeof v?v(k({},st(w),{className:V,"aria-describedby":ft,children:mt})):t.cloneElement(v,k({},st(w,v.props),{"aria-describedby":ft,children:t.createElement(t.Fragment,null,v.props.children,mt),className:f(V,v.props.className)})):mt}tt.displayName="Tooltip",tt.propTypes={children:o.node,className:o.string,align:o.oneOf(Object.values(K)),justify:o.oneOf(Object.values(a)),trigger:o.oneOfType([o.node,o.func]),triggerEvent:o.oneOf(Object.values($)),darkMode:o.bool,enabled:o.bool,open:o.bool,setOpen:o.func,id:o.string,shouldClose:o.func,usePortal:o.bool,portalClassName:o.string};export default tt;export{K as Align,$ as TriggerEvent}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,2 @@ | ||
import Tooltip, { TriggerEvent, Align, Justify } from './Tooltip'; | ||
export { TriggerEvent, Align, Justify }; | ||
export default Tooltip; | ||
//# sourceMappingURL=index.js.map | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/palette"),require("@leafygreen-ui/tokens"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/leafygreen-provider"),require("polished"),require("lodash/debounce"),require("lodash/clamp")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@leafygreen-ui/popover","@leafygreen-ui/hooks","@leafygreen-ui/emotion","@leafygreen-ui/palette","@leafygreen-ui/tokens","@leafygreen-ui/lib","@leafygreen-ui/leafygreen-provider","polished","lodash/debounce","lodash/clamp"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/tooltip"]={},e.React,e.PropTypes,e["@leafygreen-ui/popover"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/emotion"],e["@leafygreen-ui/palette"],e["@leafygreen-ui/tokens"],e["@leafygreen-ui/lib"],e["@leafygreen-ui/leafygreen-provider"],e.polished,e.debounce,e.clamp)}(this,(function(e,t,n,r,o,i,a,u,l,c,s,f,p){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g,y=d(t),b=d(n),h=d(r),v=d(f),m=d(p);function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(){return(O=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 k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function C(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}function w(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function P(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;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(e,t){if(!e)return;if("string"==typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return E(e,t)}(e,t)||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 E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function N(){var e=w(["\n min-width: ","px;\n transform: ",";\n "]);return N=function(){return e},e}function S(){var e=w(["\n ",";\n position: absolute;\n transform: rotate(45deg);\n width: 8px;\n height: 8px;\n margin: auto;\n "]);return S=function(){return e},e}function q(){var e=w(["\n position: absolute;\n width: ","px;\n height: ","px;\n overflow: hidden;\n margin: auto;\n ",";\n "]);return q=function(){return e},e}function A(){var e=w(["\n background-color: ",";\n border: 1px solid ",";\n box-shadow: 0px 2px 4px ",";\n "]);return A=function(){return e},e}function J(){var e=w(["\n color: ",";\n "]);return J=function(){return e},e}function M(){var e=w(["\n background-color: ",";\n color: ",";\n border: 1px solid ",";\n "]);return M=function(){return e},e}function T(){var e=w(["\n background-color: ",";\n box-shadow: 0px 2px 4px ",";\n "]);return T=function(){return e},e}function z(){var e=w(["\n color: ",";\n "]);return z=function(){return e},e}function F(){var e=w(["\n background-color: ",";\n color: ",";\n "]);return F=function(){return e},e}function D(){var e=w(["\n position: relative;\n"]);return D=function(){return e},e}function I(){var e=w(["\n padding: 14px 16px;\n border-radius: 3px;\n box-shadow: 0px 2px 4px ",";\n cursor: default;\n"]);return I=function(){return e},e}function B(){var e=w(["\n font-size: 16px;\n line-height: 24px;\n letter-spacing: 0px;\n"]);return B=function(){return e},e}function L(){var e=w(["\n font-size: 14px;\n line-height: 20px;\n letter-spacing: 0px;\n"]);return L=function(){return e},e}function R(){var e=w(["\n margin: unset;\n font-family: ",";\n color: ",";\n font-weight: 400;\n"]);return R=function(){return e},e}var H=i.css(R(),u.fontFamilies.default,a.uiColors.gray.dark3),X=i.css(L()),Y=i.css(B()),_={Hover:"hover",Click:"click"},K="light",U="dark",$={Top:r.Align.Top,Bottom:r.Align.Bottom,Left:r.Align.Left,Right:r.Align.Right},G=i.css(I(),s.transparentize(.85,a.uiColors.black)),Q=i.css(D()),V=(x(g={},U,{tooltip:i.css(F(),a.uiColors.gray.dark3,a.uiColors.gray.light1),children:i.css(z(),a.uiColors.gray.light1),notch:i.css(T(),a.uiColors.gray.dark3,s.transparentize(.85,a.uiColors.black))}),x(g,K,{tooltip:i.css(M(),a.uiColors.gray.light3,a.uiColors.gray.dark2,a.uiColors.gray.light2),children:i.css(J(),a.uiColors.gray.dark2),notch:i.css(A(),a.uiColors.gray.light3,a.uiColors.gray.light2,s.transparentize(.85,a.uiColors.black))}),g),W=l.IdAllocator.create("tooltip"),Z=function(e){e.preventDefault(),e.stopPropagation()};function ee(e){var n,a=e.open,u=e.setOpen,l=e.className,s=e.children,f=e.trigger,p=e.triggerEvent,d=void 0===p?_.Hover:p,g=e.darkMode,b=void 0!==g&&g,x=e.enabled,k=void 0===x||x,w=e.usePortal,E=void 0===w||w,A=e.align,J=void 0===A?"top":A,M=e.justify,T=void 0===M?"start":M,z=e.spacing,F=void 0===z?12:z,D=e.id,I=e.shouldClose,B=e.portalClassName,L=C(e,["open","setOpen","className","children","trigger","triggerEvent","darkMode","enabled","usePortal","align","justify","spacing","id","shouldClose","portalClassName"]),R="boolean"==typeof a,$=P(t.useState(!1),2),ee=$[0],te=$[1],ne=c.useBaseFontSize(),re=R?a:ee,oe=R&&u?u:te,ie=t.useRef(null),ae=null!=D?D:null===(n=ie.current)||void 0===n?void 0:n.id,ue=t.useMemo((function(){return null!=ae?ae:W.generate()}),[ae]),le=function(e,t){return e===_.Hover?{onMouseEnter:v.default((function(){oe(!0)}),35),onMouseLeave:v.default(ce,35),onFocus:function(){return oe(!0)},onBlur:ce}:t&&t.onClick?{onClick:function(e){e.target!==ie.current&&(t.onClick(),oe((function(e){return!e})))}}:{onClick:function(e){e.target!==ie.current&&oe((function(e){return!e}))}}},ce=function(){("function"!=typeof I||I())&&oe(!1)};o.useEscapeKey(ce,{enabled:re});o.useEventListener("click",(function(e){var t=ie&&ie.current;t&&!t.contains(e.target)&&ce()}),{enabled:re&&"click"===d});var se=E?{spacing:F,usePortal:E,portalClassName:B}:{spacing:F,usePortal:E},fe=b?U:K,pe=y.default.createElement(h.default,O({key:"tooltip",active:k&&re,align:J,justify:T,adjustOnMutation:!0,onClick:Z},se),(function(e){var t=function(e,t,n){if(!e||!t||!n)return{notchContainer:"",notch:"",tooltip:""};var o,a,u={},l={},c=10,s=0,f="";switch(e){case"top":case"bottom":switch(c=15,o=n.width/2-7.5,s=m.default(o,5,c),a=o<=5,u.left="0px",u.right="0px","top"===e?(l.top="100%",u.top="".concat(-4,"px")):(l.bottom="100%",u.bottom="".concat(-4,"px")),t){case r.Justify.Start:l.left="".concat(s,"px"),a&&(f="translateX(-".concat(5-o,"px)"));break;case r.Justify.Middle:case r.Justify.Fit:l.left="0px",l.right="0px";break;case r.Justify.End:l.right="".concat(s,"px"),a&&(f="translateX(".concat(5-o,"px)"))}break;case"left":case"right":switch(c=10,o=n.height/2-7.5,s=m.default(o,5,c),a=o<=5,u.top="0px",u.bottom="0px","left"===e?(u.left="".concat(-4,"px"),l.left="100%"):(u.right="".concat(-4,"px"),l.right="100%"),t){case r.Justify.Start:l.top="".concat(s,"px"),a&&(f="translateY(-".concat(5-o,"px)"));break;case r.Justify.Middle:case r.Justify.Fit:l.top="0px",l.bottom="0px";break;case r.Justify.End:l.bottom="".concat(s,"px"),a&&(f="translateY(".concat(5-o,"px)"))}}return{notchContainer:i.css(q(),15,15,i.css(l)),notch:i.css(S(),i.css(u)),tooltip:i.css(N(),2*s+15,f)}}(e.align,e.justify,e.referenceElPos),n=t.notchContainer,o=t.notch,a=t.tooltip;return y.default.createElement("div",O({},L,{role:"tooltip",id:ue,className:i.cx(G,a,V[fe].tooltip,l),ref:ie}),y.default.createElement("div",{className:n},y.default.createElement("div",{className:i.cx(o,V[fe].notch)})),y.default.createElement("div",{className:i.cx(H,16===ne?Y:X,V[fe].children)},s))}));return f?"function"==typeof f?f(j({},le(d),{className:Q,"aria-describedby":ue,children:pe})):y.default.cloneElement(f,j({},le(d,f.props),{"aria-describedby":ue,children:y.default.createElement(y.default.Fragment,null,f.props.children,pe),className:i.cx(Q,f.props.className)})):pe}ee.displayName="Tooltip",ee.propTypes={children:b.default.node,className:b.default.string,align:b.default.oneOf(Object.values($)),justify:b.default.oneOf(Object.values(r.Justify)),trigger:b.default.oneOfType([b.default.node,b.default.func]),triggerEvent:b.default.oneOf(Object.values(_)),darkMode:b.default.bool,enabled:b.default.bool,open:b.default.bool,setOpen:b.default.func,id:b.default.string,shouldClose:b.default.func,usePortal:b.default.bool,portalClassName:b.default.string},Object.defineProperty(e,"Justify",{enumerable:!0,get:function(){return r.Justify}}),e.Align=$,e.TriggerEvent=_,e.default=ee,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@leafygreen-ui/tooltip", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "LeafyGreen UI Kit Tooltip", | ||
@@ -23,12 +23,12 @@ "main": "./dist/index.js", | ||
"devDependencies": { | ||
"@leafygreen-ui/button": "^8.0.0" | ||
"@leafygreen-ui/button": "^8.0.1" | ||
}, | ||
"dependencies": { | ||
"@leafygreen-ui/popover": "^7.0.0", | ||
"@leafygreen-ui/lib": "^6.0.0", | ||
"@leafygreen-ui/palette": "^3.0.0", | ||
"@leafygreen-ui/hooks": "^5.0.0", | ||
"@leafygreen-ui/tokens": "^0.4.0", | ||
"@leafygreen-ui/popover": "^7.0.1", | ||
"@leafygreen-ui/lib": "^6.0.1", | ||
"@leafygreen-ui/palette": "^3.0.1", | ||
"@leafygreen-ui/hooks": "^5.0.1", | ||
"@leafygreen-ui/tokens": "^0.5.0", | ||
"lodash": "^4.17.20" | ||
} | ||
} |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
346387
23
1329
2
+ Added@leafygreen-ui/tokens@0.5.3(transitive)
- Removed@leafygreen-ui/tokens@0.4.0(transitive)
Updated@leafygreen-ui/hooks@^5.0.1
Updated@leafygreen-ui/lib@^6.0.1
Updated@leafygreen-ui/tokens@^0.5.0