@entur/tooltip
Advanced tools
Comparing version 5.1.4 to 5.1.5-beta.0
@@ -16,26 +16,18 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
function _objectWithoutPropertiesLoose(r, e) { | ||
if (null == r) return {}; | ||
var t = {}; | ||
for (var n in r) if ({}.hasOwnProperty.call(r, n)) { | ||
if (e.includes(n)) continue; | ||
t[n] = r[n]; | ||
} | ||
return target; | ||
return t; | ||
} | ||
@@ -202,3 +194,3 @@ | ||
})), React.createElement("div", { | ||
className: "eds-tooltip__arrow--" + (actualPlacement == null ? void 0 : (_actualPlacement$spli = actualPlacement.split('-')) == null ? void 0 : _actualPlacement$spli[0]), | ||
className: "eds-tooltip__arrow--" + (actualPlacement == null || (_actualPlacement$spli = actualPlacement.split('-')) == null ? void 0 : _actualPlacement$spli[0]), | ||
ref: tooltipArrowRef, | ||
@@ -205,0 +197,0 @@ style: { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),r=require("classnames"),n=require("@floating-ui/react"),o=require("@entur/icons"),i=require("@entur/button"),l=require("@entur/tokens"),a=require("@floating-ui/react-dom"),s=require("@entur/layout");function u(){return u=Object.assign?Object.assign.bind():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},u.apply(this,arguments)}function c(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}function f(e){switch(e){case"top-left":return"top-start";case"top-right":return"top-end";case"bottom-left":return"bottom-start";case"bottom-right":return"bottom-end";default:return e}}var d=["placement","content","children","className","isOpen","onClickCloseButton","disableHoverListener","disableFocusListener","disableKeyboardListener","disableClickListner","showCloseButton","variant","hoverDelay","style"],p=["children"],v=t.forwardRef((function(n,o){var i=n.children,l=n.className,a=n.style,c=g(),f=c.floatingStyles,d=c.popoverContentProps;return t.createElement(s.Contrast,u({className:r(l,"eds-popover")},d,{style:u({},f,d.style,a),ref:e.mergeRefs(d.ref,o)}),i)})),m=t.createContext(void 0),g=function(){var e=t.useContext(m);if(null==e)throw Error("usePopoverContext must be used within <Popover/>");return e};function y(e,t){return!!e&&(e===t||e.contains(t))}e.warnAboutMissingStyles("tooltip"),exports.Popover=function(r){var n=r.children,o=r.placement,i=void 0===o?"bottom-start":o,s=function(e,r){var n=t.useState(!1),o=void 0!==e&&void 0!==r;return o?[e,r,o]:[n[0],n[1],o]}(r.showPopover,r.setShowPopover),c=s[0],d=s[1],p=s[2],v=a.useFloating({placement:f(i),middleware:[a.offset(l.space.extraSmall),a.flip(),a.shift({padding:l.space.extraSmall,limiter:a.limitShift({offset:8})})]}),g=v.refs,b=v.floatingStyles,h=v.elements,C=v.update;t.useEffect((function(){if(c&&h.reference&&h.floating)return a.autoUpdate(h.reference,h.floating,C)}),[c,h,C]),e.useOnClickOutside([g.floating,g.reference],(function(){return d(!1)}));var w=u({"aria-haspopup":"dialog","aria-expanded":c,ref:g.setReference,type:"button"},!p&&{onClick:function(){return d((function(e){return!e}))}}),E={role:"dialog","aria-modal":!1,"aria-hidden":!c,ref:g.setFloating,style:u({},!c&&{display:"none"}),onKeyDown:function(e){"Escape"===e.key&&d(!1)},onBlur:function(e){var t=e.relatedTarget;if(t&&"-1"!==t.getAttribute("tabindex")){var r=y(g.floating.current,t),n=y(g.reference.current,t);c&&!r&&!n&&d(!1)}}};return t.createElement(m.Provider,{value:{showPopover:c,floatingStyles:b,popoverTriggerProps:w,popoverContentProps:E,closeButtonProps:{onClick:function(){return d(!1)},type:"button"}}},n)},exports.PopoverCloseButton=function(e){var r=e.children,n=c(e,p),o=g();return t.cloneElement(r,u({},o.closeButtonProps,n))},exports.PopoverContent=v,exports.PopoverTrigger=function(e){var r=e.children,n=g().popoverTriggerProps,o=t.Children.only(r);return t.cloneElement(o,n)},exports.Tooltip=function(a){var s,p,v,m=a.placement,g=a.content,y=a.children,b=a.className,h=a.isOpen,C=a.onClickCloseButton,w=void 0===C?function(){}:C,E=a.disableHoverListener,P=void 0!==E&&E,x=a.disableFocusListener,k=void 0!==x&&x,S=a.disableKeyboardListener,L=void 0===S||S,O=a.disableClickListner,T=void 0===O||O,B=a.showCloseButton,q=void 0===B||B,R=a.variant,F=a.hoverDelay,N=a.style,D=c(a,d),M=t.useState(null!=h&&h),_=M[0],j=M[1],K=t.useRef(null),I=e.useRandomId("eds-tooltip"),A=t.useRef(),H=t.useRef(),U=void 0!==h,z=n.useFloating({placement:f(m),open:_,middleware:[n.offset(l.space.extraSmall),n.flip(),n.shift({padding:l.space.extraSmall,limiter:n.limitShift({offset:8})}),n.arrow({element:K,padding:l.borderRadiuses.medium})]}),G=z.refs,J=z.floatingStyles,Q=z.middlewareData,V=z.placement,W=z.isPositioned,X=z.update,Y=z.elements;t.useEffect((function(){if(_&&Y.reference&&Y.floating)return n.autoUpdate(Y.reference,Y.floating,X)}),[_,Y,X]);var Z=function(){var e;U||(clearTimeout(H.current),A.current=setTimeout((function(){j(!0)}),null!=(e=null==F?void 0:F.enter)?e:150))},$=function(){var e;U||(clearTimeout(A.current),H.current=setTimeout((function(){j(!1)}),null!=(e=null==F?void 0:F.leave)?e:300))};t.useEffect((function(){return function(){clearTimeout(A.current),clearTimeout(H.current)}}),[]),t.useEffect((function(){void 0!==h&&j(h)}),[h]);var ee=u({"aria-describedby":_?I:void 0},!k&&!U&&{onFocus:function(){return j(!0)}},!k&&!U&&{onBlur:function(){return j(!1)}},!P&&!U&&{onMouseEnter:Z},!P&&!U&&{onMouseLeave:$},!L&&!U&&{onKeyDown:function(e){"Escape"===e.key&&j(!1)," "!==e.key&&"Enter"!==e.key||(e.preventDefault(),j(!_))}},!T&&!U&&{onClick:function(){return j(!_)}}),te=(!U||W)&&_&&g?void 0:"none";return t.createElement(t.Fragment,null,t.cloneElement(y,u({ref:G.setReference},ee)),t.createElement("div",u({className:r(b,"eds-tooltip",{"eds-tooltip--negative":"error"===R||"negative"===R}),ref:G.setFloating,style:u({},J,{display:te},N),role:"tooltip",id:I,onMouseEnter:P?void 0:Z,onMouseLeave:P?void 0:$},D),g,h&&q&&t.createElement(i.IconButton,{className:"eds-tooltip__close-button",onClick:function(){j(!1),w()},type:"button","aria-label":"Lukk tooltip"},t.createElement(o.CloseIcon,{"aria-hidden":"true"})),t.createElement("div",{className:"eds-tooltip__arrow--"+(null==V||null==(s=V.split("-"))?void 0:s[0]),ref:K,style:{left:null==(p=Q.arrow)?void 0:p.x,top:null==(v=Q.arrow)?void 0:v.y}})))},exports.standardisePlacement=f; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),n=require("classnames"),r=require("@floating-ui/react"),o=require("@entur/icons"),i=require("@entur/button"),l=require("@entur/tokens"),a=require("@floating-ui/react-dom"),s=require("@entur/layout");function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u.apply(null,arguments)}function c(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function f(e){switch(e){case"top-left":return"top-start";case"top-right":return"top-end";case"bottom-left":return"bottom-start";case"bottom-right":return"bottom-end";default:return e}}var d=["placement","content","children","className","isOpen","onClickCloseButton","disableHoverListener","disableFocusListener","disableKeyboardListener","disableClickListner","showCloseButton","variant","hoverDelay","style"],p=["children"],v=t.forwardRef((function(r,o){var i=r.children,l=r.className,a=r.style,c=g(),f=c.floatingStyles,d=c.popoverContentProps;return t.createElement(s.Contrast,u({className:n(l,"eds-popover")},d,{style:u({},f,d.style,a),ref:e.mergeRefs(d.ref,o)}),i)})),m=t.createContext(void 0),g=function(){var e=t.useContext(m);if(null==e)throw Error("usePopoverContext must be used within <Popover/>");return e};function y(e,t){return!!e&&(e===t||e.contains(t))}e.warnAboutMissingStyles("tooltip"),exports.Popover=function(n){var r=n.children,o=n.placement,i=void 0===o?"bottom-start":o,s=function(e,n){var r=t.useState(!1),o=void 0!==e&&void 0!==n;return o?[e,n,o]:[r[0],r[1],o]}(n.showPopover,n.setShowPopover),c=s[0],d=s[1],p=s[2],v=a.useFloating({placement:f(i),middleware:[a.offset(l.space.extraSmall),a.flip(),a.shift({padding:l.space.extraSmall,limiter:a.limitShift({offset:8})})]}),g=v.refs,b=v.floatingStyles,h=v.elements,C=v.update;t.useEffect((function(){if(c&&h.reference&&h.floating)return a.autoUpdate(h.reference,h.floating,C)}),[c,h,C]),e.useOnClickOutside([g.floating,g.reference],(function(){return d(!1)}));var w=u({"aria-haspopup":"dialog","aria-expanded":c,ref:g.setReference,type:"button"},!p&&{onClick:function(){return d((function(e){return!e}))}}),P={role:"dialog","aria-modal":!1,"aria-hidden":!c,ref:g.setFloating,style:u({},!c&&{display:"none"}),onKeyDown:function(e){"Escape"===e.key&&d(!1)},onBlur:function(e){var t=e.relatedTarget;if(t&&"-1"!==t.getAttribute("tabindex")){var n=y(g.floating.current,t),r=y(g.reference.current,t);c&&!n&&!r&&d(!1)}}};return t.createElement(m.Provider,{value:{showPopover:c,floatingStyles:b,popoverTriggerProps:w,popoverContentProps:P,closeButtonProps:{onClick:function(){return d(!1)},type:"button"}}},r)},exports.PopoverCloseButton=function(e){var n=e.children,r=c(e,p),o=g();return t.cloneElement(n,u({},o.closeButtonProps,r))},exports.PopoverContent=v,exports.PopoverTrigger=function(e){var n=e.children,r=g().popoverTriggerProps,o=t.Children.only(n);return t.cloneElement(o,r)},exports.Tooltip=function(a){var s,p,v,m=a.placement,g=a.content,y=a.children,b=a.className,h=a.isOpen,C=a.onClickCloseButton,w=void 0===C?function(){}:C,P=a.disableHoverListener,E=void 0!==P&&P,x=a.disableFocusListener,k=void 0!==x&&x,S=a.disableKeyboardListener,L=void 0===S||S,T=a.disableClickListner,B=void 0===T||T,q=a.showCloseButton,O=void 0===q||q,R=a.variant,F=a.hoverDelay,N=a.style,D=c(a,d),M=t.useState(null!=h&&h),_=M[0],K=M[1],j=t.useRef(null),I=e.useRandomId("eds-tooltip"),A=t.useRef(),H=t.useRef(),U=void 0!==h,z=r.useFloating({placement:f(m),open:_,middleware:[r.offset(l.space.extraSmall),r.flip(),r.shift({padding:l.space.extraSmall,limiter:r.limitShift({offset:8})}),r.arrow({element:j,padding:l.borderRadiuses.medium})]}),G=z.refs,J=z.floatingStyles,Q=z.middlewareData,V=z.placement,W=z.isPositioned,X=z.update,Y=z.elements;t.useEffect((function(){if(_&&Y.reference&&Y.floating)return r.autoUpdate(Y.reference,Y.floating,X)}),[_,Y,X]);var Z=function(){var e;U||(clearTimeout(H.current),A.current=setTimeout((function(){K(!0)}),null!=(e=null==F?void 0:F.enter)?e:150))},$=function(){var e;U||(clearTimeout(A.current),H.current=setTimeout((function(){K(!1)}),null!=(e=null==F?void 0:F.leave)?e:300))};t.useEffect((function(){return function(){clearTimeout(A.current),clearTimeout(H.current)}}),[]),t.useEffect((function(){void 0!==h&&K(h)}),[h]);var ee=u({"aria-describedby":_?I:void 0},!k&&!U&&{onFocus:function(){return K(!0)}},!k&&!U&&{onBlur:function(){return K(!1)}},!E&&!U&&{onMouseEnter:Z},!E&&!U&&{onMouseLeave:$},!L&&!U&&{onKeyDown:function(e){"Escape"===e.key&&K(!1)," "!==e.key&&"Enter"!==e.key||(e.preventDefault(),K(!_))}},!B&&!U&&{onClick:function(){return K(!_)}}),te=(!U||W)&&_&&g?void 0:"none";return t.createElement(t.Fragment,null,t.cloneElement(y,u({ref:G.setReference},ee)),t.createElement("div",u({className:n(b,"eds-tooltip",{"eds-tooltip--negative":"error"===R||"negative"===R}),ref:G.setFloating,style:u({},J,{display:te},N),role:"tooltip",id:I,onMouseEnter:E?void 0:Z,onMouseLeave:E?void 0:$},D),g,h&&O&&t.createElement(i.IconButton,{className:"eds-tooltip__close-button",onClick:function(){K(!1),w()},type:"button","aria-label":"Lukk tooltip"},t.createElement(o.CloseIcon,{"aria-hidden":"true"})),t.createElement("div",{className:"eds-tooltip__arrow--"+(null==V||null==(s=V.split("-"))?void 0:s[0]),ref:j,style:{left:null==(p=Q.arrow)?void 0:p.x,top:null==(v=Q.arrow)?void 0:v.y}})))},exports.standardisePlacement=f; | ||
//# sourceMappingURL=tooltip.cjs.production.min.js.map |
@@ -12,26 +12,18 @@ import { useRandomId, useOnClickOutside, mergeRefs, warnAboutMissingStyles } from '@entur/utils'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
function _objectWithoutPropertiesLoose(r, e) { | ||
if (null == r) return {}; | ||
var t = {}; | ||
for (var n in r) if ({}.hasOwnProperty.call(r, n)) { | ||
if (e.includes(n)) continue; | ||
t[n] = r[n]; | ||
} | ||
return target; | ||
return t; | ||
} | ||
@@ -198,3 +190,3 @@ | ||
})), React.createElement("div", { | ||
className: "eds-tooltip__arrow--" + (actualPlacement == null ? void 0 : (_actualPlacement$spli = actualPlacement.split('-')) == null ? void 0 : _actualPlacement$spli[0]), | ||
className: "eds-tooltip__arrow--" + (actualPlacement == null || (_actualPlacement$spli = actualPlacement.split('-')) == null ? void 0 : _actualPlacement$spli[0]), | ||
ref: tooltipArrowRef, | ||
@@ -201,0 +193,0 @@ style: { |
{ | ||
"name": "@entur/tooltip", | ||
"version": "5.1.4", | ||
"version": "5.1.5-beta.0", | ||
"license": "EUPL-1.2", | ||
@@ -30,7 +30,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@entur/button": "^3.2.36", | ||
"@entur/icons": "^7.5.0", | ||
"@entur/layout": "^2.3.20", | ||
"@entur/tokens": "^3.17.3", | ||
"@entur/utils": "^0.12.1", | ||
"@entur/button": "^3.2.37-beta.0", | ||
"@entur/icons": "^7.5.1-beta.0", | ||
"@entur/layout": "^2.3.21-beta.0", | ||
"@entur/tokens": "^3.17.4-beta.0", | ||
"@entur/utils": "^0.12.2-beta.0", | ||
"@floating-ui/react": "^0.26.24", | ||
@@ -40,3 +40,6 @@ "@floating-ui/react-dom": "^2.1.0", | ||
}, | ||
"gitHead": "5c9836f2bcab799e31cc52b6fe72c6e198947a71" | ||
"devDependencies": { | ||
"dts-cli": "2.0.5" | ||
}, | ||
"gitHead": "b213fa4fd10a1a07abada3fa987b7ee2ed110ac2" | ||
} |
@@ -5,3 +5,3 @@ # Tooltip | ||
> 💡 Looking for the [documentation](https://design.entur.no/komponenter/feedback/tooltips)? | ||
> 💡 Looking for the [documentation](https://design.entur.no/komponenter/feedback/tooltip)? | ||
@@ -18,2 +18,2 @@ ## Installation | ||
Please refer to the [documentation](https://design.entur.no/komponenter/feedback/tooltips) for usage information. | ||
Please refer to the [documentation](https://design.entur.no/komponenter/feedback/tooltip) for usage information. |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
187798
1
1997
3
Updated@entur/button@^3.2.37-beta.0
Updated@entur/icons@^7.5.1-beta.0
Updated@entur/layout@^2.3.21-beta.0
Updated@entur/tokens@^3.17.4-beta.0
Updated@entur/utils@^0.12.2-beta.0