@leafygreen-ui/tooltip
Advanced tools
Comparing version 2.0.1 to 2.0.2
# @leafygreen-ui/tooltip | ||
## 2.0.2 | ||
### Patch Changes | ||
- 13e3eab: Enable trigger prop to accept nested components | ||
- Updated dependencies [319844d] | ||
- @leafygreen-ui/palette@1.1.1 | ||
## 2.0.1 | ||
@@ -4,0 +12,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@leafygreen-ui/emotion"),require("react"),require("prop-types"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/palette"),require("polished"));else if("function"==typeof define&&define.amd)define(["@leafygreen-ui/emotion","react","prop-types","@leafygreen-ui/popover","@leafygreen-ui/hooks","@leafygreen-ui/palette","polished"],t);else{var r="object"==typeof exports?t(require("@leafygreen-ui/emotion"),require("react"),require("prop-types"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/palette"),require("polished")):t(e["@leafygreen-ui/emotion"],e.react,e["prop-types"],e["@leafygreen-ui/popover"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/palette"],e.polished);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(e,t,r,n,o,i,u){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(t,r){t.exports=e},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,r){var n=r(14),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();e.exports=i},function(e,t,r){var n=r(2).Symbol;e.exports=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"TriggerEvent",{enumerable:!0,get:function(){return n.TriggerEvent}}),Object.defineProperty(t,"Variant",{enumerable:!0,get:function(){return n.Variant}}),t.default=void 0;var n=function(e){if(e&&e.__esModule)return e;var t=o();if(t&&t.has(e))return t.get(e);var r={};if(null!=e){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var u=n?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(r,i,u):r[i]=e[i]}}r.default=e,t&&t.set(e,r);return r}(r(5));function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}var i=n.default;t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.Variant=t.TriggerEvent=void 0;var n,o,i=g(r(6)),u=y(r(7)),a=g(r(8)),c=r(9),f=r(0),l=r(10),s=r(11),p=y(r(12)),d=r(22);function y(e){return e&&e.__esModule?e:{default:e}}function v(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return v=function(){return e},e}function g(e){if(e&&e.__esModule)return e;var t=v();if(t&&t.has(e))return t.get(e);var r={};if(null!=e){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var i=n?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}}return r.default=e,t&&t.set(e,r),r}function b(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(r,!0).forEach((function(t){k(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function x(){return(x=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function m(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function w(){var e=T(["\n background-color: ",";\n border: 1px solid ",";\n box-shadow: 0px 2px 4px ",";\n "]);return w=function(){return e},e}function P(){var e=T(["\n background-color: ",";\n box-shadow: 0px 2px 4px ",";\n "]);return P=function(){return e},e}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function S(){var e=T(["\n background-color: ",";\n color: ",";\n border: 1px solid ",";\n "]);return S=function(){return e},e}function E(){var e=T(["\n background-color: ",";\n color: ",";\n "]);return E=function(){return e},e}function M(){var e=T(["\n font-size: 14px;\n line-height: 20px;\n padding: 14px 16px;\n border-radius: 3px;\n box-shadow: 0px 2px 4px ",";\n"]);return M=function(){return e},e}function T(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var C={Hover:"hover",Click:"click"};t.TriggerEvent=C;var _={Light:"light",Dark:"dark"};t.Variant=_;var q=(0,f.css)(M(),(0,s.transparentize)(.85,l.uiColors.black)),D=(k(n={},_.Dark,(0,f.css)(E(),l.uiColors.gray.dark3,l.uiColors.gray.light1)),k(n,_.Light,(0,f.css)(S(),l.uiColors.gray.light3,l.uiColors.gray.dark2,l.uiColors.gray.light2)),n),N=(k(o={},_.Dark,(0,f.css)(P(),l.uiColors.gray.dark3,(0,s.transparentize)(.85,l.uiColors.black))),k(o,_.Light,(0,f.css)(w(),l.uiColors.gray.light3,l.uiColors.gray.light2,(0,s.transparentize)(.85,l.uiColors.black))),o);function z(e){var t=e.open,r=e.setOpen,n=e.className,o=e.children,u=e.trigger,l=e.variant,s=void 0===l?_.Light:l,y=e.triggerEvent,v=void 0===y?C.Hover:y,g=e.align,h=void 0===g?"top":g,w=e.justify,P=void 0===w?"start":w,k=e.id,S=e.shouldClose,E=m(e,["open","setOpen","className","children","trigger","variant","triggerEvent","align","justify","id","shouldClose"]),M="boolean"==typeof t,T=j((0,i.useState)(!1),2),z=T[0],A=T[1],L=M?t:z,W=M&&r?r:A,I=(0,i.useRef)(null),V=(0,i.useMemo)((function(){return k||"tooltip-".concat(Math.floor(Math.random()*Math.floor(10)))}),[k]),$=function(e,t){return e===C.Hover?{onMouseEnter:(0,p.default)((function(){W((function(e){return!e}))}),35),onMouseLeave:(0,p.default)(F,35),onFocus:function(){return W(!0)},onBlur:F}:t&&t.onClick?{onClick:function(e){e.target!==I.current&&(t.onClick(),W((function(e){return!e})))}}:{onClick:function(e){e.target!==I.current&&W((function(e){return!e}))}}},F=function(){("function"!=typeof S||S())&&W(!1)};(0,c.useEscapeKey)(F);(0,c.useEventListener)("click",(function(e){var t=I&&I.current;t&&!t.contains(e.target)&&F()}),{enabled:L&&"click"===v});var H=i.default.createElement(a.default,{active:L,align:h,justify:P,usePortal:!0,adjustOnMutation:!0,spacing:12,key:"tooltip"},(function(e){var t=e.alignment,r=e.justification,u=e.referenceElPos,a=(0,d.trianglePosition)(t,r,u);return i.default.createElement("div",x({},E,{role:"tooltip",id:V,className:(0,f.cx)(n,q,D[s]),ref:I}),i.default.createElement("div",{className:a.containerStyle},i.default.createElement("div",{className:(0,f.cx)(a.notchStyle,N[s])})),o)}));return u?"function"==typeof u?u(O({},$(v),{"aria-describedby":V,children:H})):i.default.cloneElement(u,O({},$(v,u.props),{"aria-describedby":V,children:u.props.children?[].concat(b(u.props.children),[H]):H})):H}z.displayName="Tooltip",z.propTypes={children:u.default.node,className:u.default.string,align:u.default.oneOf(Object.values(a.Align)),justify:u.default.oneOf(Object.values(a.Justify)),trigger:u.default.oneOfType([u.default.node,u.default.func]),triggerEvent:u.default.oneOf(Object.values(C)),variant:u.default.oneOf(Object.values(_)),open:u.default.bool,setOpen:u.default.func,id:u.default.string,shouldClose:u.default.func};var A=z;t.default=A},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=i},function(e,t){e.exports=u},function(e,t,r){var n=r(1),o=r(13),i=r(16),u="Expected a function",a=Math.max,c=Math.min;e.exports=function(e,t,r){var f,l,s,p,d,y,v=0,g=!1,b=!1,h=!0;if("function"!=typeof e)throw new TypeError(u);function O(t){var r=f,n=l;return f=l=void 0,v=t,p=e.apply(n,r)}function x(e){var r=e-y;return void 0===y||r>=t||r<0||b&&e-v>=s}function j(){var e=o();if(x(e))return m(e);d=setTimeout(j,function(e){var r=t-(e-y);return b?c(r,s-(e-v)):r}(e))}function m(e){return d=void 0,h&&f?O(e):(f=l=void 0,p)}function w(){var e=o(),r=x(e);if(f=arguments,l=this,y=e,r){if(void 0===d)return function(e){return v=e,d=setTimeout(j,t),g?O(e):p}(y);if(b)return clearTimeout(d),d=setTimeout(j,t),O(y)}return void 0===d&&(d=setTimeout(j,t)),p}return t=i(t)||0,n(r)&&(g=!!r.leading,s=(b="maxWait"in r)?a(i(r.maxWait)||0,t):s,h="trailing"in r?!!r.trailing:h),w.cancel=function(){void 0!==d&&clearTimeout(d),v=0,f=y=l=d=void 0},w.flush=function(){return void 0===d?p:m(o())},w}},function(e,t,r){var n=r(2);e.exports=function(){return n.Date.now()}},function(e,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;e.exports=r}).call(this,r(15))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){var n=r(1),o=r(17),i=NaN,u=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,f=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return i;if(n(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=n(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(u,"");var r=c.test(e);return r||f.test(e)?l(e.slice(2),r?2:8):a.test(e)?i:+e}},function(e,t,r){var n=r(18),o=r(21),i="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||o(e)&&n(e)==i}},function(e,t,r){var n=r(3),o=r(19),i=r(20),u="[object Null]",a="[object Undefined]",c=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?a:u:c&&c in Object(e)?o(e):i(e)}},function(e,t,r){var n=r(3),o=Object.prototype,i=o.hasOwnProperty,u=o.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var o=u.call(e);return n&&(t?e[a]=r:delete e[a]),o}},function(e,t){var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.trianglePosition=function(e,t,r){if(!e||!t||!r)return"";var u=(r.width-15)/2,a=(r.height-15)/2,c={},f={};switch(e){case"top":case"bottom":switch(c.left="0px",c.right="0px","top"===e?(f.top="".concat("calc(100% - 1px)"),c.top="".concat(-4,"px")):(f.bottom="".concat("calc(100% - 1px)"),c.bottom="".concat(-4,"px")),t){case"left":f.left="".concat(u,"px");break;case"center-horizontal":f.left="0px",f.right="0px";break;case"right":f.right="".concat(u,"px")}break;case"left":case"right":switch(c.top="0px",c.bottom="0px","left"===e?(c.left="".concat(-4,"px"),f.left="calc(100% - 1.8px)"):(c.right="".concat(-4,"px"),f.right="".concat("calc(100% - 1px)")),t){case"top":f.top="".concat(a,"px");break;case"center-vertical":f.top="0px",f.bottom="0px";break;case"bottom":f.bottom="".concat(a,"px")}}return{containerStyle:(0,n.css)(i(),15,15,(0,n.css)(f)),notchStyle:(0,n.css)(o(),(0,n.css)(c))}};var n=r(0);function o(){var e=u(["\n ",";\n position: absolute;\n transform: rotate(45deg);\n width: 8px;\n height: 8px;\n margin: auto;\n "]);return o=function(){return e},e}function i(){var e=u(["\n position: absolute;\n width: ","px;\n height: ","px;\n overflow: hidden;\n margin: auto;\n ",";\n "]);return i=function(){return e},e}function u(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@leafygreen-ui/emotion"),require("react"),require("prop-types"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/palette"),require("polished"));else if("function"==typeof define&&define.amd)define(["@leafygreen-ui/emotion","react","prop-types","@leafygreen-ui/popover","@leafygreen-ui/hooks","@leafygreen-ui/palette","polished"],t);else{var r="object"==typeof exports?t(require("@leafygreen-ui/emotion"),require("react"),require("prop-types"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/palette"),require("polished")):t(e["@leafygreen-ui/emotion"],e.react,e["prop-types"],e["@leafygreen-ui/popover"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/palette"],e.polished);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(e,t,r,n,o,i,u){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(t,r){t.exports=e},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,r){var n=r(14),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();e.exports=i},function(e,t,r){var n=r(2).Symbol;e.exports=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"TriggerEvent",{enumerable:!0,get:function(){return n.TriggerEvent}}),Object.defineProperty(t,"Variant",{enumerable:!0,get:function(){return n.Variant}}),t.default=void 0;var n=function(e){if(e&&e.__esModule)return e;var t=o();if(t&&t.has(e))return t.get(e);var r={};if(null!=e){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var u=n?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(r,i,u):r[i]=e[i]}}r.default=e,t&&t.set(e,r);return r}(r(5));function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}var i=n.default;t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.Variant=t.TriggerEvent=void 0;var n,o,i=g(r(6)),u=y(r(7)),a=g(r(8)),c=r(9),f=r(0),l=r(10),s=r(11),p=y(r(12)),d=r(22);function y(e){return e&&e.__esModule?e:{default:e}}function v(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return v=function(){return e},e}function g(e){if(e&&e.__esModule)return e;var t=v();if(t&&t.has(e))return t.get(e);var r={};if(null!=e){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var i=n?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}}return r.default=e,t&&t.set(e,r),r}function b(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(r,!0).forEach((function(t){k(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function x(){return(x=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function m(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function w(){var e=T(["\n background-color: ",";\n border: 1px solid ",";\n box-shadow: 0px 2px 4px ",";\n "]);return w=function(){return e},e}function P(){var e=T(["\n background-color: ",";\n box-shadow: 0px 2px 4px ",";\n "]);return P=function(){return e},e}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function S(){var e=T(["\n background-color: ",";\n color: ",";\n border: 1px solid ",";\n "]);return S=function(){return e},e}function E(){var e=T(["\n background-color: ",";\n color: ",";\n "]);return E=function(){return e},e}function M(){var e=T(["\n font-size: 14px;\n line-height: 20px;\n padding: 14px 16px;\n border-radius: 3px;\n box-shadow: 0px 2px 4px ",";\n"]);return M=function(){return e},e}function T(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var C={Hover:"hover",Click:"click"};t.TriggerEvent=C;var _={Light:"light",Dark:"dark"};t.Variant=_;var q=(0,f.css)(M(),(0,s.transparentize)(.85,l.uiColors.black)),D=(k(n={},_.Dark,(0,f.css)(E(),l.uiColors.gray.dark3,l.uiColors.gray.light1)),k(n,_.Light,(0,f.css)(S(),l.uiColors.gray.light3,l.uiColors.gray.dark2,l.uiColors.gray.light2)),n),A=(k(o={},_.Dark,(0,f.css)(P(),l.uiColors.gray.dark3,(0,s.transparentize)(.85,l.uiColors.black))),k(o,_.Light,(0,f.css)(w(),l.uiColors.gray.light3,l.uiColors.gray.light2,(0,s.transparentize)(.85,l.uiColors.black))),o);function N(e){var t=e.open,r=e.setOpen,n=e.className,o=e.children,u=e.trigger,l=e.variant,s=void 0===l?_.Light:l,y=e.triggerEvent,v=void 0===y?C.Hover:y,g=e.align,h=void 0===g?"top":g,w=e.justify,P=void 0===w?"start":w,k=e.id,S=e.shouldClose,E=m(e,["open","setOpen","className","children","trigger","variant","triggerEvent","align","justify","id","shouldClose"]),M="boolean"==typeof t,T=j((0,i.useState)(!1),2),N=T[0],z=T[1],L=M?t:N,W=M&&r?r:z,I=(0,i.useRef)(null),V=(0,i.useMemo)((function(){return k||"tooltip-".concat(Math.floor(Math.random()*Math.floor(10)))}),[k]),$=function(e,t){return e===C.Hover?{onMouseEnter:(0,p.default)((function(){W((function(e){return!e}))}),35),onMouseLeave:(0,p.default)(F,35),onFocus:function(){return W(!0)},onBlur:F}:t&&t.onClick?{onClick:function(e){e.target!==I.current&&(t.onClick(),W((function(e){return!e})))}}:{onClick:function(e){e.target!==I.current&&W((function(e){return!e}))}}},F=function(){("function"!=typeof S||S())&&W(!1)};(0,c.useEscapeKey)(F);(0,c.useEventListener)("click",(function(e){var t=I&&I.current;t&&!t.contains(e.target)&&F()}),{enabled:L&&"click"===v});var H=i.default.createElement(a.default,{active:L,align:h,justify:P,usePortal:!0,adjustOnMutation:!0,spacing:12,key:"tooltip"},(function(e){var t=e.alignment,r=e.justification,u=e.referenceElPos,a=(0,d.trianglePosition)(t,r,u);return i.default.createElement("div",x({},E,{role:"tooltip",id:V,className:(0,f.cx)(n,q,D[s]),ref:I}),i.default.createElement("div",{className:a.containerStyle},i.default.createElement("div",{className:(0,f.cx)(a.notchStyle,A[s])})),o)}));if(u){if("function"==typeof u)return u(O({},$(v),{"aria-describedby":V,children:H}));var B=u.props.children;return i.default.cloneElement(u,O({},$(v,u.props),{"aria-describedby":V,children:B?[].concat(b(B instanceof Array?B:[B]),[H]):H}))}return H}N.displayName="Tooltip",N.propTypes={children:u.default.node,className:u.default.string,align:u.default.oneOf(Object.values(a.Align)),justify:u.default.oneOf(Object.values(a.Justify)),trigger:u.default.oneOfType([u.default.node,u.default.func]),triggerEvent:u.default.oneOf(Object.values(C)),variant:u.default.oneOf(Object.values(_)),open:u.default.bool,setOpen:u.default.func,id:u.default.string,shouldClose:u.default.func};var z=N;t.default=z},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=o},function(e,t){e.exports=i},function(e,t){e.exports=u},function(e,t,r){var n=r(1),o=r(13),i=r(16),u="Expected a function",a=Math.max,c=Math.min;e.exports=function(e,t,r){var f,l,s,p,d,y,v=0,g=!1,b=!1,h=!0;if("function"!=typeof e)throw new TypeError(u);function O(t){var r=f,n=l;return f=l=void 0,v=t,p=e.apply(n,r)}function x(e){var r=e-y;return void 0===y||r>=t||r<0||b&&e-v>=s}function j(){var e=o();if(x(e))return m(e);d=setTimeout(j,function(e){var r=t-(e-y);return b?c(r,s-(e-v)):r}(e))}function m(e){return d=void 0,h&&f?O(e):(f=l=void 0,p)}function w(){var e=o(),r=x(e);if(f=arguments,l=this,y=e,r){if(void 0===d)return function(e){return v=e,d=setTimeout(j,t),g?O(e):p}(y);if(b)return clearTimeout(d),d=setTimeout(j,t),O(y)}return void 0===d&&(d=setTimeout(j,t)),p}return t=i(t)||0,n(r)&&(g=!!r.leading,s=(b="maxWait"in r)?a(i(r.maxWait)||0,t):s,h="trailing"in r?!!r.trailing:h),w.cancel=function(){void 0!==d&&clearTimeout(d),v=0,f=y=l=d=void 0},w.flush=function(){return void 0===d?p:m(o())},w}},function(e,t,r){var n=r(2);e.exports=function(){return n.Date.now()}},function(e,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;e.exports=r}).call(this,r(15))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){var n=r(1),o=r(17),i=NaN,u=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,f=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return i;if(n(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=n(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(u,"");var r=c.test(e);return r||f.test(e)?l(e.slice(2),r?2:8):a.test(e)?i:+e}},function(e,t,r){var n=r(18),o=r(21),i="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||o(e)&&n(e)==i}},function(e,t,r){var n=r(3),o=r(19),i=r(20),u="[object Null]",a="[object Undefined]",c=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?a:u:c&&c in Object(e)?o(e):i(e)}},function(e,t,r){var n=r(3),o=Object.prototype,i=o.hasOwnProperty,u=o.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var o=u.call(e);return n&&(t?e[a]=r:delete e[a]),o}},function(e,t){var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.trianglePosition=function(e,t,r){if(!e||!t||!r)return"";var u=(r.width-15)/2,a=(r.height-15)/2,c={},f={};switch(e){case"top":case"bottom":switch(c.left="0px",c.right="0px","top"===e?(f.top="".concat("calc(100% - 1px)"),c.top="".concat(-4,"px")):(f.bottom="".concat("calc(100% - 1px)"),c.bottom="".concat(-4,"px")),t){case"left":f.left="".concat(u,"px");break;case"center-horizontal":f.left="0px",f.right="0px";break;case"right":f.right="".concat(u,"px")}break;case"left":case"right":switch(c.top="0px",c.bottom="0px","left"===e?(c.left="".concat(-4,"px"),f.left="calc(100% - 1.8px)"):(c.right="".concat(-4,"px"),f.right="".concat("calc(100% - 1px)")),t){case"top":f.top="".concat(a,"px");break;case"center-vertical":f.top="0px",f.bottom="0px";break;case"bottom":f.bottom="".concat(a,"px")}}return{containerStyle:(0,n.css)(i(),15,15,(0,n.css)(f)),notchStyle:(0,n.css)(o(),(0,n.css)(c))}};var n=r(0);function o(){var e=u(["\n ",";\n position: absolute;\n transform: rotate(45deg);\n width: 8px;\n height: 8px;\n margin: auto;\n "]);return o=function(){return e},e}function i(){var e=u(["\n position: absolute;\n width: ","px;\n height: ","px;\n overflow: hidden;\n margin: auto;\n ",";\n "]);return i=function(){return e},e}function u(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}}])})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@leafygreen-ui/tooltip", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "LeafyGreen UI Kit Tooltip", | ||
@@ -17,5 +17,5 @@ "main": "./dist/index.js", | ||
"@leafygreen-ui/lib": "^3.2.0", | ||
"@leafygreen-ui/palette": "^1.1.0", | ||
"@leafygreen-ui/palette": "^1.1.1", | ||
"@leafygreen-ui/hooks": "^1.1.0" | ||
} | ||
} |
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
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
480087
829