@progress/kendo-react-tooltip 8.2.0-develop.9 → 8.2.1-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-dom"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-common","@progress/kendo-react-popup"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).KendoReactTooltip={},t.React,t.ReactDOM,t.PropTypes,t.KendoReactCommon,t.KendoReactPopup)}(this,(function(t,e,o,n,i,l){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}})),e.default=t,Object.freeze(e)}var s=r(e),a=r(o);const p=["k-tooltip-content","k-animation-container","k-tooltip","k-tooltip-title","k-tooltip k-tooltip-closable","k-icon k-i-close"],c=t=>{if(null===t)return!1;let e=t;for(;e;){if(null!==e&&e.classList&&e.classList.contains("k-tooltip"))return!0;e=null!==e.parentNode&&e.parentNode}return p.filter((e=>e===t.className)).length>0},u={name:"@progress/kendo-react-tooltip",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},h=class t extends s.PureComponent{constructor(t){super(t),this.context=0,this.state={targetElement:null,open:!1,title:""},this.top=0,this.left=0,this.willOpen=!1,this.handleMouseOut=t=>{const{targetElement:e}=this.state,o=e?e.ownerDocument:document;let n=o&&o.elementFromPoint(t.clientX,t.clientY);c(n)||this.props.open||(clearInterval(this.updateIntervalId),this.willOpen=!1,this.onClose(t))},this.handleMouseOver=t=>{const e=t.target;!this.isVisible(e)||c(e)||e===this.state.targetElement||this.showToolTip(t)},this.handleBodyMousemove=t=>{this.top=t.clientY,this.left=t.clientX},this.onClose=t=>{i.dispatchEvent(this.props.onClose,t,this,void 0),this.setState({targetElement:null,open:!1,title:""})},this.setUpdateInterval=()=>{this.props.updateInterval&&(this.updateIntervalId=setInterval(this.onIntervalUpdate,this.props.updateInterval))},this.onIntervalUpdate=()=>{const t=this.state.targetElement;t&&(null===t.parentElement?this.onClose({target:t}):this.showToolTip({target:t}))},this.position=t=>{let e=(t=>null!==t?t.getBoundingClientRect():document.body.getBoundingClientRect())(this.state.targetElement);const o=((t,e,o,n,i)=>{switch(i){case"bottom":case"top":return"pointer"===n?t-e/2:o.left-e/2+o.width/2;case"left":return"pointer"===n?t-e-10:o.left-e-10;case"right":return"pointer"===n?t+10:o.right+10;default:return"pointer"===n?t<window.screen.availWidth/2?t-10:t-e+10:t<window.screen.availWidth/2?o.left:o.right-e}})(this.left,t.offsetWidth,e,this.props.anchorElement,this.props.position),n=((t,e,o,n,i)=>{switch(i){case"bottom":return"pointer"===n?t+10:e.bottom+10;case"left":case"right":return"pointer"===n?t-o/2:e.top-o/2+e.height/2;case"top":return"pointer"===n?t-o-10:e.top-o-10;default:return"pointer"===n?t<window.innerHeight/2?t+10:t-o-10:t<window.innerHeight/2?e.bottom+10:e.top-o-10}})(this.top,e,t.offsetHeight,this.props.anchorElement,this.props.position);return{left:o,top:n}},this.getTitle=t=>{for(;t;){if(null!==t.getAttribute("title")||t.titleExpando)return{title:t.getAttribute("title")||t.titleExpando,element:t};t=this.props.parentTitle&&t.parentElement||null}return{title:"",element:t}},this.calloutClassName=()=>{switch(this.props.position){case"bottom":return"k-callout k-callout-n";case"left":return"k-callout k-callout-e";case"right":return"k-callout k-callout-w";case"top":return"k-callout k-callout-s";default:return this.top<window.innerHeight/2?"k-callout k-callout-n":"k-callout k-callout-s"}},this.getCurrentZIndex=()=>this.context?this.context:100,i.validatePackage(u)}componentDidMount(){document&&document.body.addEventListener("mousemove",this.handleBodyMousemove)}componentWillUnmount(){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),document&&document.body.removeEventListener("mousemove",this.handleBodyMousemove)}componentDidUpdate(){this.props.open&&this.props.targetElement&&this.showToolTip({target:this.props.targetElement})}render(){if(this.props.children){const{children:e,...o}=this.props;let n=null;return s.createElement("div",{onMouseOver:t=>{n&&n.handleMouseOver(t)},onMouseOut:t=>{n&&n.handleMouseOut(t)}},s.createElement(t,{ref:t=>n=t,...o}),e)}if(!1===this.props.open)return null;const{targetElement:e}=this.state,o=this.getCurrentZIndex();return e&&this.state.title&&e.ownerDocument&&a.createPortal(s.createElement("div",{ref:t=>{if(!t)return;let e;if(this.props.onPosition){const o={element:t,targetElement:this.state.targetElement,mouseTop:this.top,mouseLeft:this.left,anchorElement:this.props.anchorElement,position:this.props.position,target:this,syntheticEvent:null,nativeEvent:null};e=this.props.onPosition.call(void 0,o)}else e=this.position(t);t.style.left=e.left+"px",t.style.top=e.top+"px"},className:i.classNames("k-animation-container","k-animation-container-fixed","k-animation-container-shown",this.props.className),style:{zIndex:o,...this.props.style},tabIndex:0},s.createElement("div",{className:"k-child-animation-container"},s.createElement("div",{id:this.props.id,role:"tooltip",className:i.classNames("k-tooltip",this.props.tooltipClassName),style:{position:"relative",...this.props.tooltipStyle}},s.createElement("div",{className:"k-tooltip-content"},this.props.content&&s.createElement(this.props.content,{title:this.state.title,target:this.state.targetElement})||this.state.title),this.props.showCallout&&s.createElement("div",{ref:t=>{t&&(t.className=this.calloutClassName(),"auto"===this.props.position&&(this.left<window.screen.availWidth/2?t.style.left=this.props.setCalloutOnPositionAuto||"25%":t.style.left=this.props.setCalloutOnPositionAuto||"75%"))}})))),this.props.appendTo?this.props.appendTo:e.ownerDocument.body)}showToolTip(t){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),t.target.hasChildNodes()&&t.target.childNodes.forEach((e=>{"title"===e.nodeName&&(t.target.titleExpando=e.innerHTML,e.remove())}));const e=this.props.targetElement||t.target;let o=this.getTitle(e);o.title?(o.element&&(o.element.titleExpando=o.title,o.element.title=""),this.willOpen=!0,this.props.openDelay?this.openTimeoutId=window.setTimeout((()=>{this.willOpen&&this.setState({targetElement:e,open:!0,title:o.title},this.setUpdateInterval)}),this.props.openDelay):this.setState({targetElement:e,open:!0,title:o.title},this.setUpdateInterval),this.state.title!==o.title&&i.dispatchEvent(this.props.onOpen,t,this,void 0)):this.state.open&&this.onClose(t)}isVisible(t){return!this.props.filter||this.props.filter(t)}};h.propTypes={anchorElement:n.oneOf(["pointer","target"]),content:n.func,filter:n.func,openDelay:n.number,position:n.oneOf(["right","left","top","bottom","auto"]),updateInterval:n.number},h.defaultProps={anchorElement:"pointer",openDelay:400,position:"auto",showCallout:!0,parentTitle:!1},h.contextType=i.ZIndexContext;let d=h;const m=s.forwardRef(((t,e)=>{const o=s.useRef(null),n=s.useRef(null),{alignment:l=f.alignment,orientation:r=f.orientation}=t;return s.useImperativeHandle(n,(()=>({props:t,element:o.current}))),s.useImperativeHandle(e,(()=>n.current)),s.createElement("div",{ref:o,className:i.classNames("k-popover-actions","k-actions",{[`k-actions-${l}`]:l,[`k-actions-${r}`]:r})},t.children)})),f={alignment:"stretched",orientation:"horizontal"};m.propTypes={alignment:n.oneOf(["start","center","end","stretched"]),orientation:n.oneOf(["horizontal","vertical"]),children:n.oneOfType([n.element,n.node])},m.displayName="KendoReactPopoverActionsBar";const v={top:"k-callout-s",left:"k-callout-e",bottom:"k-callout-n",right:"k-callout-w"},g={top:"k-callout-n",left:"k-callout-w",bottom:"k-callout-s",right:"k-callout-e"},y={top:{vertical:"bottom",horizontal:"center"},left:{vertical:"center",horizontal:"right"},bottom:{vertical:"top",horizontal:"center"},right:{vertical:"center",horizontal:"left"}},E={top:{vertical:"top",horizontal:"center"},left:{vertical:"center",horizontal:"left"},bottom:{vertical:"bottom",horizontal:"center"},right:{vertical:"center",horizontal:"right"}},k=t=>s.Children.toArray(t).filter((t=>t&&t.type===m)),b=t=>s.Children.toArray(t).filter((t=>t&&t.type!==m)),w=s.forwardRef(((t,e)=>{i.validatePackage(u);const{callout:o=T.callout,position:n=T.position,collision:r=T.collision,title:a,children:p,show:c,anchor:h,appendTo:d,offset:m,animate:f,positionMode:w,scale:O,popoverClass:I,className:C,id:N,style:x,contentStyle:P,onPosition:R,onClose:D,onOpen:M}=t,[z,A]=s.useState(!1),j="top"===n||"bottom"===n,K=t.margin||{vertical:o&&j?15:0,horizontal:o&&!j?15:0},U=y[n],H=E[n],B=s.useContext(i.ZIndexContext),L=B?B+2e3:12e3,S=s.useRef(null);s.useImperativeHandle(S,(()=>({props:t}))),s.useImperativeHandle(e,(()=>S.current));const q=s.useCallback((t=>{if(setTimeout((()=>A(t.flipped))),R){const e={target:S.current,flipped:t.flipped,fitted:t.fitted};R.call(void 0,e)}}),[R,A]),W=s.useCallback((()=>{if(M){const t={target:S.current};M.call(void 0,t)}}),[M]),Z=s.useCallback((()=>{if(D){const t={target:S.current};D.call(void 0,t)}}),[D]),V={"k-popover":!0};Array.isArray(I)?I.forEach((t=>V[t]=!0)):"object"==typeof I?Object.keys(I).forEach((t=>{V[t]=I[t]})):I&&(V[I]=!0);const F=z?g[n]:v[n],X=s.useMemo((()=>s.createElement(s.Fragment,null,a&&s.createElement("div",{className:"k-popover-header"},a),s.createElement("div",{className:"k-popover-body",style:P},b(p)),k(p))),[p,P,a]);return s.createElement(i.ZIndexContext.Provider,{value:L},s.createElement(l.Popup,{id:N,role:"tooltip",animate:f,collision:r,anchor:h,offset:m,margin:K,popupAlign:U,anchorAlign:H,appendTo:d,show:c,scale:O,positionMode:w,style:x,className:C,popupClass:V,onOpen:W,onClose:Z,onPosition:q},o&&n?s.createElement(s.Fragment,null,s.createElement("div",{className:i.classNames("k-popover-callout",F)}),s.createElement("div",{className:"k-popover-inner"},X)):X))})),T={callout:!0,position:"top",collision:{horizontal:"none",vertical:"none"}};w.propTypes={callout:n.bool,title:n.node,position:n.oneOf(["top","left","bottom","right"]),show:n.bool,animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),anchor:function(t){const e=t.anchor;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `anchor` supplied to `Kendo React Popover`. Validation failed."):null},appendTo:function(t){const e=t.appendTo;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `appendTo` supplied to `Kendo React Popover`. Validation failed."):null},positionMode:n.oneOf(["fixed","absolute"]),scale:n.number,offset:n.shape({left:n.number,top:n.number}),children:n.oneOfType([n.element,n.node]),className:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),id:n.string,popoverClass:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),style:n.object,onClose:n.func,onPosition:n.func,onOpen:n.func},w.displayName="KendoReactPopover",t.Popover=w,t.PopoverActionsBar=m,t.Tooltip=d}));
8
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-dom"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-common","@progress/kendo-react-popup"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).KendoReactTooltip={},t.React,t.ReactDOM,t.PropTypes,t.KendoReactCommon,t.KendoReactPopup)}(this,(function(t,e,o,n,i,l){"use strict";function s(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}})),e.default=t,Object.freeze(e)}var r=s(e),a=s(o);const p=["k-tooltip-content","k-animation-container","k-tooltip","k-tooltip-title","k-tooltip k-tooltip-closable","k-icon k-i-close"],c=t=>{if(null===t)return!1;let e=t;for(;e;){if(null!==e&&e.classList&&e.classList.contains("k-tooltip"))return!0;e=null!==e.parentNode&&e.parentNode}return p.filter((e=>e===t.className)).length>0},u={name:"@progress/kendo-react-tooltip",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},h=class t extends r.PureComponent{constructor(t){super(t),this.context=0,this.state={targetElement:null,open:!1,title:""},this.top=0,this.left=0,this.willOpen=!1,this.handleMouseOut=t=>{const{targetElement:e}=this.state,o=e?e.ownerDocument:document;let n=o&&o.elementFromPoint(t.clientX,t.clientY);c(n)||this.props.open||(clearInterval(this.updateIntervalId),this.willOpen=!1,this.onClose(t))},this.compareTargets=t=>this.state.targetElement===t.nativeEvent.target,this.handleEscape=t=>{const e=this.compareTargets(t);this.state.open&&e&&this.onClose(t)},this.handleTargetItemClick=t=>{const e=this.compareTargets(t);this.state.open&&e?this.onClose(t):this.showToolTip(t)},this.handleKeyDown=(t,e)=>{const o=t.key;"Escape"===t.key?this.handleEscape(t):e.includes(o)&&this.handleMouseOver(t)},this.handleMouseOver=t=>{const e=t.target;!this.isVisible(e)||c(e)||e===this.state.targetElement||this.showToolTip(t)},this.handleBodyMousemove=t=>{this.top=t.clientY,this.left=t.clientX},this.onClose=t=>{i.dispatchEvent(this.props.onClose,t,this,void 0),this.setState({targetElement:null,open:!1,title:""})},this.setUpdateInterval=()=>{this.props.updateInterval&&(this.updateIntervalId=setInterval(this.onIntervalUpdate,this.props.updateInterval))},this.onIntervalUpdate=()=>{const t=this.state.targetElement;t&&(null===t.parentElement?this.onClose({target:t}):this.showToolTip({target:t}))},this.position=t=>{let e=null!==(o=this.state.targetElement)?o.getBoundingClientRect():document.body.getBoundingClientRect();var o;const n=((t,e,o,n,i)=>{switch(i){case"bottom":case"top":return"pointer"===n?t-e/2:o.left-e/2+o.width/2;case"left":return"pointer"===n?t-e-10:o.left-e-10;case"right":return"pointer"===n?t+10:o.right+10;default:return"pointer"===n?t<window.screen.availWidth/2?t-10:t-e+10:t<window.screen.availWidth/2?o.left:o.right-e}})(this.left,t.offsetWidth,e,this.props.anchorElement,this.props.position),i=((t,e,o,n,i)=>{switch(i){case"bottom":return"pointer"===n?t+10:e.bottom+10;case"left":case"right":return"pointer"===n?t-o/2:e.top-o/2+e.height/2;case"top":return"pointer"===n?t-o-10:e.top-o-10;default:return"pointer"===n?t<window.innerHeight/2?t+10:t-o-10:t<window.innerHeight/2?e.bottom+10:e.top-o-10}})(this.top,e,t.offsetHeight,this.props.anchorElement,this.props.position);return{left:n,top:i}},this.getTitle=t=>{for(;t;){if(null!==t.getAttribute("title")||t.titleExpando)return{title:t.getAttribute("title")||t.titleExpando,element:t};t=this.props.parentTitle&&t.parentElement||null}return{title:"",element:t}},this.calloutClassName=()=>{switch(this.props.position){case"bottom":return"k-callout k-callout-n";case"left":return"k-callout k-callout-e";case"right":return"k-callout k-callout-w";case"top":return"k-callout k-callout-s";default:return this.top<window.innerHeight/2?"k-callout k-callout-n":"k-callout k-callout-s"}},this.getCurrentZIndex=()=>this.context?this.context:100,i.validatePackage(u)}componentDidMount(){document&&document.body.addEventListener("mousemove",this.handleBodyMousemove)}componentWillUnmount(){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),document&&document.body.removeEventListener("mousemove",this.handleBodyMousemove)}componentDidUpdate(){this.props.open&&this.props.targetElement&&this.showToolTip({target:this.props.targetElement})}render(){if(this.props.children){const{children:e,showOption:o,...n}=this.props;let i=null;const l=void 0===(null==o?void 0:o.hover)||(null==o?void 0:o.hover),s=void 0!==(null==o?void 0:o.click)&&(null==o?void 0:o.click),a=void 0!==(null==o?void 0:o.focus)&&(null==o?void 0:o.focus),p=void 0!==(null==o?void 0:o.none)&&(null==o?void 0:o.none),c=(void 0!==(null==o?void 0:o.keys)?null==o?void 0:o.keys:[]).map((t=>"Space"===t?" ":t));return r.createElement("div",{onMouseOver:t=>{i&&!p&&l&&i.handleMouseOver(t)},onMouseOut:t=>{i&&!p&&l&&i.handleMouseOut(t)},onClick:t=>{i&&!p&&s&&i.handleTargetItemClick(t)},onFocus:t=>{i&&!p&&a&&i.handleMouseOver(t)},onKeyDown:t=>{(i&&!p&&c.length>0||i&&!p&&"Escape"===t.key)&&i.handleKeyDown(t,c)}},r.createElement(t,{ref:t=>i=t,...n}),e)}if(!1===this.props.open)return null;const{targetElement:e}=this.state,o=this.getCurrentZIndex();return e&&this.state.title&&e.ownerDocument&&a.createPortal(r.createElement("div",{ref:t=>{if(!t)return;let e;if(this.props.onPosition){const o={element:t,targetElement:this.state.targetElement,mouseTop:this.top,mouseLeft:this.left,anchorElement:this.props.anchorElement,position:this.props.position,target:this,syntheticEvent:null,nativeEvent:null};e=this.props.onPosition.call(void 0,o)}else e=this.position(t);t.style.left=e.left+"px",t.style.top=e.top+"px"},className:i.classNames("k-animation-container","k-animation-container-fixed","k-animation-container-shown",this.props.className),style:{zIndex:o,...this.props.style},tabIndex:0},r.createElement("div",{className:"k-child-animation-container"},r.createElement("div",{id:this.props.id,role:"tooltip",className:i.classNames("k-tooltip",this.props.tooltipClassName),style:{position:"relative",...this.props.tooltipStyle}},r.createElement("div",{className:"k-tooltip-content"},this.props.content&&r.createElement(this.props.content,{title:this.state.title,target:this.state.targetElement})||this.state.title),this.props.showCallout&&r.createElement("div",{ref:t=>{t&&(t.className=this.calloutClassName(),"auto"===this.props.position&&(this.left<window.screen.availWidth/2?t.style.left=this.props.setCalloutOnPositionAuto||"25%":t.style.left=this.props.setCalloutOnPositionAuto||"75%"))}})))),this.props.appendTo?this.props.appendTo:e.ownerDocument.body)}showToolTip(t){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),t.target.hasChildNodes()&&t.target.childNodes.forEach((e=>{"title"===e.nodeName&&(t.target.titleExpando=e.innerHTML,e.remove())}));const e=this.props.targetElement||t.target;let o=this.getTitle(e);o.title?(o.element&&(o.element.titleExpando=o.title,o.element.title=""),this.willOpen=!0,this.props.openDelay?this.openTimeoutId=window.setTimeout((()=>{this.willOpen&&this.setState({targetElement:e,open:!0,title:o.title},this.setUpdateInterval)}),this.props.openDelay):this.setState({targetElement:e,open:!0,title:o.title},this.setUpdateInterval),this.state.title!==o.title&&i.dispatchEvent(this.props.onOpen,t,this,void 0)):this.state.open&&this.onClose(t)}isVisible(t){return!this.props.filter||this.props.filter(t)}};h.propTypes={anchorElement:n.oneOf(["pointer","target"]),content:n.func,filter:n.func,openDelay:n.number,position:n.oneOf(["right","left","top","bottom","auto"]),updateInterval:n.number,showOption:n.object},h.defaultProps={anchorElement:"pointer",openDelay:400,position:"auto",showCallout:!0,parentTitle:!1},h.contextType=i.ZIndexContext;let d=h;const m=r.forwardRef(((t,e)=>{const o=r.useRef(null),n=r.useRef(null),{alignment:l=f.alignment,orientation:s=f.orientation}=t;return r.useImperativeHandle(n,(()=>({props:t,element:o.current}))),r.useImperativeHandle(e,(()=>n.current)),r.createElement("div",{ref:o,className:i.classNames("k-popover-actions","k-actions",{[`k-actions-${l}`]:l,[`k-actions-${s}`]:s})},t.children)})),f={alignment:"stretched",orientation:"horizontal"};m.propTypes={alignment:n.oneOf(["start","center","end","stretched"]),orientation:n.oneOf(["horizontal","vertical"]),children:n.oneOfType([n.element,n.node])},m.displayName="KendoReactPopoverActionsBar";const v=t=>{if(t){const e=t.querySelectorAll(i.FOCUSABLE_ELEMENTS.join(", "));if(e.length)return e[0]}},g=t=>{const e=v(document.querySelector(".k-popover-inner")),o=(t=>{if(t){const e=t.querySelectorAll(i.FOCUSABLE_ELEMENTS.join(", "));if(e.length)return e[e.length-1]}})(document.querySelector(".k-popover-inner"));t.shiftKey&&t.target===e?(o&&o.focus(),t.preventDefault()):!t.shiftKey&&t.target===o&&(e&&e.focus(),t.preventDefault())},y={top:"k-callout-s",left:"k-callout-e",bottom:"k-callout-n",right:"k-callout-w"},E={top:"k-callout-n",left:"k-callout-w",bottom:"k-callout-s",right:"k-callout-e"},k={top:{vertical:"bottom",horizontal:"center"},left:{vertical:"center",horizontal:"right"},bottom:{vertical:"top",horizontal:"center"},right:{vertical:"center",horizontal:"left"}},b={top:{vertical:"top",horizontal:"center"},left:{vertical:"center",horizontal:"left"},bottom:{vertical:"bottom",horizontal:"center"},right:{vertical:"center",horizontal:"right"}},T=t=>r.Children.toArray(t).filter((t=>t&&t.type===m)),w=t=>r.Children.toArray(t).filter((t=>t&&t.type!==m)),O=r.forwardRef(((t,e)=>{i.validatePackage(u);const{callout:o=C.callout,position:n=C.position,collision:s=C.collision,title:a,children:p,show:c,anchor:h,appendTo:d,offset:m,animate:f,positionMode:O,scale:I,popoverClass:N,className:x,id:P,style:D,contentStyle:M,onPosition:R,onClose:A,onOpen:K,onKeyDown:S}=t,[j,z]=r.useState(!1),U="top"===n||"bottom"===n,L=t.margin||{vertical:o&&U?15:0,horizontal:o&&!U?15:0},q=k[n],B=b[n],H=r.useContext(i.ZIndexContext),F=H?H+2e3:12e3,W=r.useRef(null);r.useImperativeHandle(W,(()=>({props:t}))),r.useImperativeHandle(e,(()=>W.current));const Z=r.useCallback((t=>{if(setTimeout((()=>z(t.flipped))),R){const e={target:W.current,flipped:t.flipped,fitted:t.fitted};R.call(void 0,e)}}),[R,z]),V=r.useCallback((()=>{const t=v(document.querySelector(".k-popover-inner"));if(t&&t.focus(),K){const t={target:W.current};K.call(void 0,t)}}),[K]),X=r.useCallback((t=>{if(S&&"Escape"===t.key){const t={target:W.current,show:!1};S.call(void 0,t)}"Tab"===t.key&&g(t)}),[S]),Y=r.useCallback((t=>{if(A){const t={target:W.current};A.call(void 0,t)}t&&t.target&&t.target.props&&t.target.props.anchor&&t.target.props.anchor.focus()}),[A]),$={"k-popover":!0};Array.isArray(N)?N.forEach((t=>$[t]=!0)):"object"==typeof N?Object.keys(N).forEach((t=>{$[t]=N[t]})):N&&($[N]=!0);const _=j?E[n]:y[n],G=r.useMemo((()=>r.createElement(r.Fragment,null,a&&r.createElement("div",{className:"k-popover-header"},a),r.createElement("div",{className:"k-popover-body",style:M},w(p)),T(p))),[p,M,a]);return r.createElement(i.ZIndexContext.Provider,{value:F},r.createElement(l.Popup,{id:P,role:"tooltip",animate:f,collision:s,anchor:h,offset:m,margin:L,popupAlign:q,anchorAlign:B,appendTo:d,show:c,scale:I,positionMode:O,style:D,className:x,popupClass:$,onOpen:V,onClose:Y,onPosition:Z,onKeyDown:X},o&&n?r.createElement(r.Fragment,null,r.createElement("div",{className:i.classNames("k-popover-callout",_)}),r.createElement("div",{className:"k-popover-inner"},G)):G))})),C={callout:!0,position:"top",collision:{horizontal:"none",vertical:"none"}};O.propTypes={callout:n.bool,title:n.node,position:n.oneOf(["top","left","bottom","right"]),show:n.bool,animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),anchor:function(t){const e=t.anchor;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `anchor` supplied to `Kendo React Popover`. Validation failed."):null},appendTo:function(t){const e=t.appendTo;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `appendTo` supplied to `Kendo React Popover`. Validation failed."):null},positionMode:n.oneOf(["fixed","absolute"]),scale:n.number,offset:n.shape({left:n.number,top:n.number}),children:n.oneOfType([n.element,n.node]),className:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),id:n.string,popoverClass:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),style:n.object,onClose:n.func,onPosition:n.func,onOpen:n.func},O.displayName="KendoReactPopover",t.Popover=O,t.PopoverActionsBar=m,t.Tooltip=d}));
package/index.d.mts CHANGED
@@ -119,6 +119,20 @@ export declare interface PopoverHandle {
119
119
  props: PopoverProps;
120
120
  }
121
121
 
122
+ /**
123
+ * Represents the object of the `KeyDown` Popover event.
124
+ */
125
+ export declare interface PopoverKeyDownEvent {
126
+ /**
127
+ * An event target.
128
+ */
129
+ target: PopoverHandle;
130
+ /**
131
+ * A boolean value that indicates whether the Popover is visible.
132
+ */
133
+ show?: boolean;
134
+ }
135
+
122
136
  /**
123
137
  * Defines the horizontal and the vertical margin offset of the component.
124
138
  */
@@ -287,6 +301,10 @@ export declare interface PopoverProps {
287
301
  * Fires after the Popover position is set.
288
302
  */
289
303
  onPosition?: (event: PopoverPositionEvent) => void;
304
+ /**
305
+ * Fires when the Popover is focused and a key is pressed.
306
+ */
307
+ onKeyDown?: (event: PopoverKeyDownEvent) => void;
290
308
  /**
291
309
  * @hidden
292
310
  */
@@ -304,6 +322,7 @@ export declare class Tooltip extends React_2.PureComponent<TooltipProps, Tooltip
304
322
  openDelay: PropTypes.Requireable<number>;
305
323
  position: PropTypes.Requireable<string>;
306
324
  updateInterval: PropTypes.Requireable<number>;
325
+ showOption: PropTypes.Requireable<object>;
307
326
  };
308
327
  static defaultProps: {
309
328
  anchorElement: string;
@@ -346,6 +365,13 @@ export declare class Tooltip extends React_2.PureComponent<TooltipProps, Tooltip
346
365
  * The method is used on the MouseOut event to hide the Tooltip.
347
366
  */
348
367
  handleMouseOut: (event: any) => void;
368
+ private compareTargets;
369
+ private handleEscape;
370
+ /**
371
+ * @hidden
372
+ */
373
+ handleTargetItemClick: (event: React_2.MouseEvent<HTMLDivElement, MouseEvent>) => void;
374
+ private handleKeyDown;
349
375
  /**
350
376
  * Used on the `MouseOver` event to show the Tooltip.
351
377
  */
@@ -436,6 +462,16 @@ export declare interface TooltipProps {
436
462
  * Sets a class of the Tooltip animation container.
437
463
  */
438
464
  className?: string;
465
+ /**
466
+ * Specifies when the Тooltip will be rendered.
467
+ * The available options are:
468
+ * - `hover`&mdash;Shows the Tooltip when the mouse hovers over the target element(Set to `true` by default).
469
+ * - `click`&mdash;Shows the Tooltip when the target element is clicked(Set to `false` by default).
470
+ * - `focus`&mdash;Shows the Tooltip when the target element is focused(Set to `false` by default).
471
+ * - `keys`&mdash;Shows the Tooltip when the target element is focused and a specific key is pressed(Set to `false` by default).
472
+ * - `none`&mdash;Doesn't show the Tooltip(Set to `false` by default).
473
+ */
474
+ showOption?: TooltipShowOptions;
439
475
  /**
440
476
  * Sets the content of the Tooltip ([see example]({% slug templates_tooltip %})).
441
477
  */
@@ -508,6 +544,22 @@ export declare interface TooltipProps {
508
544
  updateInterval?: number;
509
545
  }
510
546
 
547
+ /**
548
+ * Specifies when the options of the [showTooltip]({slug: api_tooltip_tooltipprops}#toc-showoption) props.
549
+ * - `hover`&mdash;Shows the Tooltip when the mouse hovers over the target element(Set to `true` by default).
550
+ * - `click`&mdash;Shows the Tooltip when the target element is clicked(Set to `false` by default).
551
+ * - `focus`&mdash;Shows the Tooltip when the target element is focused(Set to `false` by default).
552
+ * - `keys`&mdash;Shows the Tooltip when the target element is focused and a specific key is pressed(Set to `false` by default).
553
+ * - `none`&mdash;Doesn't show the Tooltip(Set to `false` by default).
554
+ */
555
+ declare type TooltipShowOptions = {
556
+ hover?: boolean;
557
+ click?: boolean;
558
+ focus?: boolean;
559
+ keys?: string[];
560
+ none?: boolean;
561
+ };
562
+
511
563
  /**
512
564
  * @hidden
513
565
  */
package/index.d.ts CHANGED
@@ -119,6 +119,20 @@ export declare interface PopoverHandle {
119
119
  props: PopoverProps;
120
120
  }
121
121
 
122
+ /**
123
+ * Represents the object of the `KeyDown` Popover event.
124
+ */
125
+ export declare interface PopoverKeyDownEvent {
126
+ /**
127
+ * An event target.
128
+ */
129
+ target: PopoverHandle;
130
+ /**
131
+ * A boolean value that indicates whether the Popover is visible.
132
+ */
133
+ show?: boolean;
134
+ }
135
+
122
136
  /**
123
137
  * Defines the horizontal and the vertical margin offset of the component.
124
138
  */
@@ -287,6 +301,10 @@ export declare interface PopoverProps {
287
301
  * Fires after the Popover position is set.
288
302
  */
289
303
  onPosition?: (event: PopoverPositionEvent) => void;
304
+ /**
305
+ * Fires when the Popover is focused and a key is pressed.
306
+ */
307
+ onKeyDown?: (event: PopoverKeyDownEvent) => void;
290
308
  /**
291
309
  * @hidden
292
310
  */
@@ -304,6 +322,7 @@ export declare class Tooltip extends React_2.PureComponent<TooltipProps, Tooltip
304
322
  openDelay: PropTypes.Requireable<number>;
305
323
  position: PropTypes.Requireable<string>;
306
324
  updateInterval: PropTypes.Requireable<number>;
325
+ showOption: PropTypes.Requireable<object>;
307
326
  };
308
327
  static defaultProps: {
309
328
  anchorElement: string;
@@ -346,6 +365,13 @@ export declare class Tooltip extends React_2.PureComponent<TooltipProps, Tooltip
346
365
  * The method is used on the MouseOut event to hide the Tooltip.
347
366
  */
348
367
  handleMouseOut: (event: any) => void;
368
+ private compareTargets;
369
+ private handleEscape;
370
+ /**
371
+ * @hidden
372
+ */
373
+ handleTargetItemClick: (event: React_2.MouseEvent<HTMLDivElement, MouseEvent>) => void;
374
+ private handleKeyDown;
349
375
  /**
350
376
  * Used on the `MouseOver` event to show the Tooltip.
351
377
  */
@@ -436,6 +462,16 @@ export declare interface TooltipProps {
436
462
  * Sets a class of the Tooltip animation container.
437
463
  */
438
464
  className?: string;
465
+ /**
466
+ * Specifies when the Тooltip will be rendered.
467
+ * The available options are:
468
+ * - `hover`&mdash;Shows the Tooltip when the mouse hovers over the target element(Set to `true` by default).
469
+ * - `click`&mdash;Shows the Tooltip when the target element is clicked(Set to `false` by default).
470
+ * - `focus`&mdash;Shows the Tooltip when the target element is focused(Set to `false` by default).
471
+ * - `keys`&mdash;Shows the Tooltip when the target element is focused and a specific key is pressed(Set to `false` by default).
472
+ * - `none`&mdash;Doesn't show the Tooltip(Set to `false` by default).
473
+ */
474
+ showOption?: TooltipShowOptions;
439
475
  /**
440
476
  * Sets the content of the Tooltip ([see example]({% slug templates_tooltip %})).
441
477
  */
@@ -508,6 +544,22 @@ export declare interface TooltipProps {
508
544
  updateInterval?: number;
509
545
  }
510
546
 
547
+ /**
548
+ * Specifies when the options of the [showTooltip]({slug: api_tooltip_tooltipprops}#toc-showoption) props.
549
+ * - `hover`&mdash;Shows the Tooltip when the mouse hovers over the target element(Set to `true` by default).
550
+ * - `click`&mdash;Shows the Tooltip when the target element is clicked(Set to `false` by default).
551
+ * - `focus`&mdash;Shows the Tooltip when the target element is focused(Set to `false` by default).
552
+ * - `keys`&mdash;Shows the Tooltip when the target element is focused and a specific key is pressed(Set to `false` by default).
553
+ * - `none`&mdash;Doesn't show the Tooltip(Set to `false` by default).
554
+ */
555
+ declare type TooltipShowOptions = {
556
+ hover?: boolean;
557
+ click?: boolean;
558
+ focus?: boolean;
559
+ keys?: string[];
560
+ none?: boolean;
561
+ };
562
+
511
563
  /**
512
564
  * @hidden
513
565
  */
@@ -10,7 +10,7 @@ const e = {
10
10
  name: "@progress/kendo-react-tooltip",
11
11
  productName: "KendoReact",
12
12
  productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
13
- publishDate: 1720780450,
13
+ publishDate: 1723022995,
14
14
  version: "",
15
15
  licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-react-tooltip",
3
- "version": "8.2.0-develop.9",
3
+ "version": "8.2.1-develop.1",
4
4
  "description": "React Tooltips library represents popups with information that is related to a UI element. KendoReact Tooltips package",
5
5
  "author": "Progress",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -23,8 +23,8 @@
23
23
  "sideEffects": false,
24
24
  "peerDependencies": {
25
25
  "@progress/kendo-licensing": "^1.3.4",
26
- "@progress/kendo-react-common": "8.2.0-develop.9",
27
- "@progress/kendo-react-popup": "8.2.0-develop.9",
26
+ "@progress/kendo-react-common": "8.2.1-develop.1",
27
+ "@progress/kendo-react-popup": "8.2.1-develop.1",
28
28
  "@progress/kendo-svg-icons": "^3.0.0",
29
29
  "react": "^16.8.2 || ^17.0.0 || ^18.0.0",
30
30
  "react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react"),e=require("prop-types"),p=require("@progress/kendo-react-common"),X=require("../package-metadata.js"),G=require("@progress/kendo-react-popup"),E=require("./PopoverActionsBar.js");function J(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const a in o)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(o,a);Object.defineProperty(n,a,l.get?l:{enumerable:!0,get:()=>o[a]})}}return n.default=o,Object.freeze(n)}const t=J(U),Q=12e3,W=2e3,C=15,Y={top:"k-callout-s",left:"k-callout-e",bottom:"k-callout-n",right:"k-callout-w"},$={top:"k-callout-n",left:"k-callout-w",bottom:"k-callout-s",right:"k-callout-e"},ee={top:{vertical:"bottom",horizontal:"center"},left:{vertical:"center",horizontal:"right"},bottom:{vertical:"top",horizontal:"center"},right:{vertical:"center",horizontal:"left"}},te={top:{vertical:"top",horizontal:"center"},left:{vertical:"center",horizontal:"left"},bottom:{vertical:"bottom",horizontal:"center"},right:{vertical:"center",horizontal:"right"}},oe=o=>t.Children.toArray(o).filter(n=>n&&n.type===E.PopoverActionsBar),ne=o=>t.Children.toArray(o).filter(n=>n&&n.type!==E.PopoverActionsBar),h=t.forwardRef((o,n)=>{p.validatePackage(X.packageMetadata);const{callout:a=b.callout,position:l=b.position,collision:T=b.collision,title:u,children:d,show:A,anchor:z,appendTo:R,offset:N,animate:j,positionMode:x,scale:I,popoverClass:i,className:w,id:S,style:_,contentStyle:g,onPosition:f,onClose:m,onOpen:v}=o,[D,y]=t.useState(!1),P=l==="top"||l==="bottom",M=o.margin||{vertical:a&&P?C:0,horizontal:a&&!P?C:0},q=ee[l],B=te[l],O=t.useContext(p.ZIndexContext),Z=O?O+W:Q,c=t.useRef(null);t.useImperativeHandle(c,()=>({props:o})),t.useImperativeHandle(n,()=>c.current);const F=t.useCallback(r=>{if(setTimeout(()=>y(r.flipped)),f){const H={target:c.current,flipped:r.flipped,fitted:r.fitted};f.call(void 0,H)}},[f,y]),V=t.useCallback(()=>{if(v){const r={target:c.current};v.call(void 0,r)}},[v]),K=t.useCallback(()=>{if(m){const r={target:c.current};m.call(void 0,r)}},[m]),s={"k-popover":!0};Array.isArray(i)?i.forEach(r=>s[r]=!0):typeof i=="object"?Object.keys(i).forEach(r=>{s[r]=i[r]}):i&&(s[i]=!0);const L=D?$[l]:Y[l],k=t.useMemo(()=>t.createElement(t.Fragment,null,u&&t.createElement("div",{className:"k-popover-header"},u),t.createElement("div",{className:"k-popover-body",style:g},ne(d)),oe(d)),[d,g,u]);return t.createElement(p.ZIndexContext.Provider,{value:Z},t.createElement(G.Popup,{id:S,role:"tooltip",animate:j,collision:T,anchor:z,offset:N,margin:M,popupAlign:q,anchorAlign:B,appendTo:R,show:A,scale:I,positionMode:x,style:_,className:w,popupClass:s,onOpen:V,onClose:K,onPosition:F},a&&l?t.createElement(t.Fragment,null,t.createElement("div",{className:p.classNames("k-popover-callout",L)}),t.createElement("div",{className:"k-popover-inner"},k)):k))}),b={callout:!0,position:"top",collision:{horizontal:"none",vertical:"none"}};h.propTypes={callout:e.bool,title:e.node,position:e.oneOf(["top","left","bottom","right"]),show:e.bool,animate:e.oneOfType([e.bool,e.shape({openDuration:e.number,closeDuration:e.number})]),anchor:function(o){const n=o.anchor;return n&&typeof n.nodeType!="number"?new Error("Invalid prop `anchor` supplied to `Kendo React Popover`. Validation failed."):null},appendTo:function(o){const n=o.appendTo;return n&&typeof n.nodeType!="number"?new Error("Invalid prop `appendTo` supplied to `Kendo React Popover`. Validation failed."):null},positionMode:e.oneOf(["fixed","absolute"]),scale:e.number,offset:e.shape({left:e.number,top:e.number}),children:e.oneOfType([e.element,e.node]),className:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),id:e.string,popoverClass:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),style:e.object,onClose:e.func,onPosition:e.func,onOpen:e.func};h.displayName="KendoReactPopover";exports.Popover=h;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("react"),e=require("prop-types"),u=require("@progress/kendo-react-common"),Q=require("../package-metadata.js"),W=require("@progress/kendo-react-popup"),w=require("./PopoverActionsBar.js"),T=require("./utils.js");function Y(n){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const l in n)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(n,l);Object.defineProperty(r,l,a.get?a:{enumerable:!0,get:()=>n[l]})}}return r.default=n,Object.freeze(r)}const t=Y(J),$=12e3,ee=2e3,A=15,te={top:"k-callout-s",left:"k-callout-e",bottom:"k-callout-n",right:"k-callout-w"},oe={top:"k-callout-n",left:"k-callout-w",bottom:"k-callout-s",right:"k-callout-e"},ne={top:{vertical:"bottom",horizontal:"center"},left:{vertical:"center",horizontal:"right"},bottom:{vertical:"top",horizontal:"center"},right:{vertical:"center",horizontal:"left"}},re={top:{vertical:"top",horizontal:"center"},left:{vertical:"center",horizontal:"left"},bottom:{vertical:"bottom",horizontal:"center"},right:{vertical:"center",horizontal:"right"}},ae=n=>t.Children.toArray(n).filter(r=>r&&r.type===w.PopoverActionsBar),le=n=>t.Children.toArray(n).filter(r=>r&&r.type!==w.PopoverActionsBar),y=t.forwardRef((n,r)=>{u.validatePackage(Q.packageMetadata);const{callout:l=b.callout,position:a=b.position,collision:z=b.collision,title:d,children:f,show:R,anchor:N,appendTo:j,offset:D,animate:x,positionMode:I,scale:S,popoverClass:c,className:q,id:F,style:_,contentStyle:P,onPosition:m,onClose:v,onOpen:g,onKeyDown:h}=n,[M,k]=t.useState(!1),O=a==="top"||a==="bottom",B=n.margin||{vertical:l&&O?A:0,horizontal:l&&!O?A:0},K=ne[a],Z=re[a],C=t.useContext(u.ZIndexContext),V=C?C+ee:$,s=t.useRef(null);t.useImperativeHandle(s,()=>({props:n})),t.useImperativeHandle(r,()=>s.current);const L=t.useCallback(o=>{if(setTimeout(()=>k(o.flipped)),m){const i={target:s.current,flipped:o.flipped,fitted:o.fitted};m.call(void 0,i)}},[m,k]),H=t.useCallback(()=>{const o=T.getFirstFocusableElement(document.querySelector(".k-popover-inner"));if(o&&o.focus(),g){const i={target:s.current};g.call(void 0,i)}},[g]),U=t.useCallback(o=>{if(h&&o.key==="Escape"){const i={target:s.current,show:!1};h.call(void 0,i)}o.key==="Tab"&&T.handleFocusTrap(o)},[h]),X=t.useCallback(o=>{if(v){const i={target:s.current};v.call(void 0,i)}o&&o.target&&o.target.props&&o.target.props.anchor&&o.target.props.anchor.focus()},[v]),p={"k-popover":!0};Array.isArray(c)?c.forEach(o=>p[o]=!0):typeof c=="object"?Object.keys(c).forEach(o=>{p[o]=c[o]}):c&&(p[c]=!0);const G=M?oe[a]:te[a],E=t.useMemo(()=>t.createElement(t.Fragment,null,d&&t.createElement("div",{className:"k-popover-header"},d),t.createElement("div",{className:"k-popover-body",style:P},le(f)),ae(f)),[f,P,d]);return t.createElement(u.ZIndexContext.Provider,{value:V},t.createElement(W.Popup,{id:F,role:"tooltip",animate:x,collision:z,anchor:N,offset:D,margin:B,popupAlign:K,anchorAlign:Z,appendTo:j,show:R,scale:S,positionMode:I,style:_,className:q,popupClass:p,onOpen:H,onClose:X,onPosition:L,onKeyDown:U},l&&a?t.createElement(t.Fragment,null,t.createElement("div",{className:u.classNames("k-popover-callout",G)}),t.createElement("div",{className:"k-popover-inner"},E)):E))}),b={callout:!0,position:"top",collision:{horizontal:"none",vertical:"none"}};y.propTypes={callout:e.bool,title:e.node,position:e.oneOf(["top","left","bottom","right"]),show:e.bool,animate:e.oneOfType([e.bool,e.shape({openDuration:e.number,closeDuration:e.number})]),anchor:function(n){const r=n.anchor;return r&&typeof r.nodeType!="number"?new Error("Invalid prop `anchor` supplied to `Kendo React Popover`. Validation failed."):null},appendTo:function(n){const r=n.appendTo;return r&&typeof r.nodeType!="number"?new Error("Invalid prop `appendTo` supplied to `Kendo React Popover`. Validation failed."):null},positionMode:e.oneOf(["fixed","absolute"]),scale:e.number,offset:e.shape({left:e.number,top:e.number}),children:e.oneOfType([e.element,e.node]),className:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),id:e.string,popoverClass:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),style:e.object,onClose:e.func,onPosition:e.func,onOpen:e.func};y.displayName="KendoReactPopover";exports.Popover=y;
@@ -8,116 +8,130 @@
8
8
  "use client";
9
9
  import * as o from "react";
10
10
  import e from "prop-types";
11
- import { validatePackage as X, ZIndexContext as C, classNames as q } from "@progress/kendo-react-common";
12
- import { packageMetadata as G } from "../package-metadata.mjs";
13
- import { Popup as J } from "@progress/kendo-react-popup";
14
- import { PopoverActionsBar as k } from "./PopoverActionsBar.mjs";
15
- const Q = 12e3, W = 2e3, E = 15, Y = {
11
+ import { validatePackage as G, ZIndexContext as C, classNames as J } from "@progress/kendo-react-common";
12
+ import { packageMetadata as Q } from "../package-metadata.mjs";
13
+ import { Popup as W } from "@progress/kendo-react-popup";
14
+ import { PopoverActionsBar as T } from "./PopoverActionsBar.mjs";
15
+ import { getFirstFocusableElement as Y, handleFocusTrap as $ } from "./utils.mjs";
16
+ const ee = 12e3, oe = 2e3, O = 15, te = {
16
17
  top: "k-callout-s",
17
18
  left: "k-callout-e",
18
19
  bottom: "k-callout-n",
19
20
  right: "k-callout-w"
20
- }, $ = {
21
+ }, ne = {
21
22
  top: "k-callout-n",
22
23
  left: "k-callout-w",
23
24
  bottom: "k-callout-s",
24
25
  right: "k-callout-e"
25
- }, ee = {
26
+ }, re = {
26
27
  top: { vertical: "bottom", horizontal: "center" },
27
28
  left: { vertical: "center", horizontal: "right" },
28
29
  bottom: { vertical: "top", horizontal: "center" },
29
30
  right: { vertical: "center", horizontal: "left" }
30
- }, oe = {
31
+ }, le = {
31
32
  top: { vertical: "top", horizontal: "center" },
32
33
  left: { vertical: "center", horizontal: "left" },
33
34
  bottom: { vertical: "bottom", horizontal: "center" },
34
35
  right: { vertical: "center", horizontal: "right" }
35
- }, te = (r) => o.Children.toArray(r).filter((t) => t && t.type === k), ne = (r) => o.Children.toArray(r).filter((t) => t && t.type !== k), O = o.forwardRef((r, t) => {
36
- X(G);
36
+ }, ae = (r) => o.Children.toArray(r).filter((n) => n && n.type === T), ie = (r) => o.Children.toArray(r).filter((n) => n && n.type !== T), A = o.forwardRef((r, n) => {
37
+ G(Q);
37
38
  const {
38
- callout: s = v.callout,
39
- position: l = v.position,
40
- collision: T = v.collision,
41
- title: p,
42
- children: u,
43
- show: A,
44
- anchor: z,
45
- appendTo: N,
46
- offset: R,
47
- animate: x,
48
- positionMode: I,
49
- scale: w,
39
+ callout: p = g.callout,
40
+ position: l = g.position,
41
+ collision: w = g.collision,
42
+ title: u,
43
+ children: f,
44
+ show: z,
45
+ anchor: N,
46
+ appendTo: R,
47
+ offset: x,
48
+ animate: D,
49
+ positionMode: F,
50
+ scale: I,
50
51
  popoverClass: a,
51
- className: j,
52
- id: D,
53
- style: F,
54
- contentStyle: h,
55
- onPosition: f,
56
- onClose: d,
57
- onOpen: m
58
- } = r, [V, b] = o.useState(!1), g = l === "top" || l === "bottom", Z = r.margin || {
59
- vertical: s && g ? E : 0,
60
- horizontal: s && !g ? E : 0
61
- }, _ = ee[l], B = oe[l], y = o.useContext(C), M = y ? y + W : Q, i = o.useRef(null);
62
- o.useImperativeHandle(i, () => ({ props: r })), o.useImperativeHandle(t, () => i.current);
63
- const S = o.useCallback(
64
- (n) => {
65
- if (setTimeout(() => b(n.flipped)), f) {
66
- const U = { target: i.current, flipped: n.flipped, fitted: n.fitted };
67
- f.call(void 0, U);
52
+ className: K,
53
+ id: j,
54
+ style: S,
55
+ contentStyle: y,
56
+ onPosition: d,
57
+ onClose: m,
58
+ onOpen: h,
59
+ onKeyDown: v
60
+ } = r, [V, b] = o.useState(!1), P = l === "top" || l === "bottom", Z = r.margin || {
61
+ vertical: p && P ? O : 0,
62
+ horizontal: p && !P ? O : 0
63
+ }, _ = re[l], B = le[l], k = o.useContext(C), M = k ? k + oe : ee, c = o.useRef(null);
64
+ o.useImperativeHandle(c, () => ({ props: r })), o.useImperativeHandle(n, () => c.current);
65
+ const L = o.useCallback(
66
+ (t) => {
67
+ if (setTimeout(() => b(t.flipped)), d) {
68
+ const i = { target: c.current, flipped: t.flipped, fitted: t.fitted };
69
+ d.call(void 0, i);
68
70
  }
69
71
  },
70
- [f, b]
71
- ), K = o.useCallback(
72
+ [d, b]
73
+ ), H = o.useCallback(
72
74
  () => {
73
- if (m) {
74
- const n = { target: i.current };
75
- m.call(void 0, n);
75
+ const t = Y(document.querySelector(".k-popover-inner"));
76
+ if (t && t.focus(), h) {
77
+ const i = { target: c.current };
78
+ h.call(void 0, i);
76
79
  }
77
80
  },
78
- [m]
79
- ), L = o.useCallback(
80
- () => {
81
- if (d) {
82
- const n = { target: i.current };
83
- d.call(void 0, n);
81
+ [h]
82
+ ), U = o.useCallback(
83
+ (t) => {
84
+ if (v && t.key === "Escape") {
85
+ const i = { target: c.current, show: !1 };
86
+ v.call(void 0, i);
84
87
  }
88
+ t.key === "Tab" && $(t);
85
89
  },
86
- [d]
87
- ), c = { "k-popover": !0 };
88
- Array.isArray(a) ? a.forEach((n) => c[n] = !0) : typeof a == "object" ? Object.keys(a).forEach((n) => {
89
- c[n] = a[n];
90
- }) : a && (c[a] = !0);
91
- const H = V ? $[l] : Y[l], P = o.useMemo(
92
- () => /* @__PURE__ */ o.createElement(o.Fragment, null, p && /* @__PURE__ */ o.createElement("div", { className: "k-popover-header" }, p), /* @__PURE__ */ o.createElement("div", { className: "k-popover-body", style: h }, ne(u)), te(u)),
93
- [u, h, p]
90
+ [v]
91
+ ), X = o.useCallback(
92
+ (t) => {
93
+ if (m) {
94
+ const i = { target: c.current };
95
+ m.call(void 0, i);
96
+ }
97
+ t && t.target && t.target.props && t.target.props.anchor && t.target.props.anchor.focus();
98
+ },
99
+ [m]
100
+ ), s = { "k-popover": !0 };
101
+ Array.isArray(a) ? a.forEach((t) => s[t] = !0) : typeof a == "object" ? Object.keys(a).forEach((t) => {
102
+ s[t] = a[t];
103
+ }) : a && (s[a] = !0);
104
+ const q = V ? ne[l] : te[l], E = o.useMemo(
105
+ () => /* @__PURE__ */ o.createElement(o.Fragment, null, u && /* @__PURE__ */ o.createElement("div", { className: "k-popover-header" }, u), /* @__PURE__ */ o.createElement("div", { className: "k-popover-body", style: y }, ie(f)), ae(f)),
106
+ [f, y, u]
94
107
  );
95
108
  return /* @__PURE__ */ o.createElement(C.Provider, { value: M }, /* @__PURE__ */ o.createElement(
96
- J,
109
+ W,
97
110
  {
98
- id: D,
111
+ id: j,
99
112
  role: "tooltip",
100
- animate: x,
101
- collision: T,
102
- anchor: z,
103
- offset: R,
113
+ animate: D,
114
+ collision: w,
115
+ anchor: N,
116
+ offset: x,
104
117
  margin: Z,
105
118
  popupAlign: _,
106
119
  anchorAlign: B,
107
- appendTo: N,
108
- show: A,
109
- scale: w,
110
- positionMode: I,
111
- style: F,
112
- className: j,
113
- popupClass: c,
114
- onOpen: K,
115
- onClose: L,
116
- onPosition: S
120
+ appendTo: R,
121
+ show: z,
122
+ scale: I,
123
+ positionMode: F,
124
+ style: S,
125
+ className: K,
126
+ popupClass: s,
127
+ onOpen: H,
128
+ onClose: X,
129
+ onPosition: L,
130
+ onKeyDown: U
117
131
  },
118
- s && l ? /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement("div", { className: q("k-popover-callout", H) }), /* @__PURE__ */ o.createElement("div", { className: "k-popover-inner" }, P)) : P
132
+ p && l ? /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement("div", { className: J("k-popover-callout", q) }), /* @__PURE__ */ o.createElement("div", { className: "k-popover-inner" }, E)) : E
119
133
  ));
120
- }), v = {
134
+ }), g = {
121
135
  callout: !0,
122
136
  position: "top",
123
137
  collision: {
@@ -125,7 +139,7 @@ const Q = 12e3, W = 2e3, E = 15, Y = {
125
139
  vertical: "none"
126
140
  }
127
141
  };
128
- O.propTypes = {
142
+ A.propTypes = {
129
143
  callout: e.bool,
130
144
  title: e.node,
131
145
  position: e.oneOf(["top", "left", "bottom", "right"]),
@@ -138,14 +152,14 @@ O.propTypes = {
138
152
  })
139
153
  ]),
140
154
  anchor: function(r) {
141
- const t = r.anchor;
142
- return t && typeof t.nodeType != "number" ? new Error(
155
+ const n = r.anchor;
156
+ return n && typeof n.nodeType != "number" ? new Error(
143
157
  "Invalid prop `anchor` supplied to `Kendo React Popover`. Validation failed."
144
158
  ) : null;
145
159
  },
146
160
  appendTo: function(r) {
147
- const t = r.appendTo;
148
- return t && typeof t.nodeType != "number" ? new Error(
161
+ const n = r.appendTo;
162
+ return n && typeof n.nodeType != "number" ? new Error(
149
163
  "Invalid prop `appendTo` supplied to `Kendo React Popover`. Validation failed."
150
164
  ) : null;
151
165
  },
@@ -178,7 +192,7 @@ O.propTypes = {
178
192
  onPosition: e.func,
179
193
  onOpen: e.func
180
194
  };
181
- O.displayName = "KendoReactPopover";
195
+ A.displayName = "KendoReactPopover";
182
196
  export {
183
- O as Popover
197
+ A as Popover
184
198
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@progress/kendo-react-common"),r=e=>{if(e){const t=e.querySelectorAll(n.FOCUSABLE_ELEMENTS.join(", "));if(t.length)return t[0]}},l=e=>{if(e){const t=e.querySelectorAll(n.FOCUSABLE_ELEMENTS.join(", "));if(t.length)return t[t.length-1]}},s=e=>{const t=r(document.querySelector(".k-popover-inner")),o=l(document.querySelector(".k-popover-inner"));e.shiftKey&&e.target===t?(o&&o.focus(),e.preventDefault()):!e.shiftKey&&e.target===o&&(t&&t.focus(),e.preventDefault())};exports.getFirstFocusableElement=r;exports.getLastFocusableElement=l;exports.handleFocusTrap=s;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use client";
9
+ import { FOCUSABLE_ELEMENTS as n } from "@progress/kendo-react-common";
10
+ const r = (e) => {
11
+ if (e) {
12
+ const t = e.querySelectorAll(n.join(", "));
13
+ if (t.length)
14
+ return t[0];
15
+ }
16
+ }, l = (e) => {
17
+ if (e) {
18
+ const t = e.querySelectorAll(n.join(", "));
19
+ if (t.length)
20
+ return t[t.length - 1];
21
+ }
22
+ }, c = (e) => {
23
+ const t = r(document.querySelector(".k-popover-inner")), o = l(document.querySelector(".k-popover-inner"));
24
+ e.shiftKey && e.target === t ? (o && o.focus(), e.preventDefault()) : !e.shiftKey && e.target === o && (t && t.focus(), e.preventDefault());
25
+ };
26
+ export {
27
+ r as getFirstFocusableElement,
28
+ l as getLastFocusableElement,
29
+ c as handleFocusTrap
30
+ };
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),f=require("react-dom"),l=require("prop-types"),r=require("@progress/kendo-react-common"),c=require("./utils.js"),g=require("../package-metadata.js");function d(p){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const t in p)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(p,t);Object.defineProperty(s,t,e.get?e:{enumerable:!0,get:()=>p[t]})}}return s.default=p,Object.freeze(s)}const n=d(m),E=d(f),v=100,a=class a extends n.PureComponent{constructor(s){super(s),this.context=0,this.state={targetElement:null,open:!1,title:""},this.top=0,this.left=0,this.willOpen=!1,this.handleMouseOut=t=>{const{targetElement:e}=this.state,o=e?e.ownerDocument:document;let i=o&&o.elementFromPoint(t.clientX,t.clientY);c.isTooltipElement(i)||this.props.open||(clearInterval(this.updateIntervalId),this.willOpen=!1,this.onClose(t))},this.handleMouseOver=t=>{const e=t.target;!this.isVisible(e)||c.isTooltipElement(e)||e===this.state.targetElement||this.showToolTip(t)},this.handleBodyMousemove=t=>{this.top=t.clientY,this.left=t.clientX},this.onClose=t=>{r.dispatchEvent(this.props.onClose,t,this,void 0),this.setState({targetElement:null,open:!1,title:""})},this.setUpdateInterval=()=>{this.props.updateInterval&&(this.updateIntervalId=setInterval(this.onIntervalUpdate,this.props.updateInterval))},this.onIntervalUpdate=()=>{const t=this.state.targetElement;t&&(t.parentElement===null?this.onClose({target:t}):this.showToolTip({target:t}))},this.position=t=>{let e=c.getDomRect(this.state.targetElement);const o=c.getLeftPosition(this.left,t.offsetWidth,e,this.props.anchorElement,this.props.position),i=c.getTopPosition(this.top,e,t.offsetHeight,this.props.anchorElement,this.props.position);return{left:o,top:i}},this.getTitle=t=>{for(;t;){if(t.getAttribute("title")!==null||t.titleExpando)return{title:t.getAttribute("title")||t.titleExpando,element:t};t=this.props.parentTitle&&t.parentElement||null}return{title:"",element:t}},this.calloutClassName=()=>{switch(this.props.position){case"bottom":return"k-callout k-callout-n";case"left":return"k-callout k-callout-e";case"right":return"k-callout k-callout-w";case"top":return"k-callout k-callout-s";default:return this.top<window.innerHeight/2?"k-callout k-callout-n":"k-callout k-callout-s"}},this.getCurrentZIndex=()=>this.context?this.context:v,r.validatePackage(g.packageMetadata)}componentDidMount(){document&&document.body.addEventListener("mousemove",this.handleBodyMousemove)}componentWillUnmount(){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),document&&document.body.removeEventListener("mousemove",this.handleBodyMousemove)}componentDidUpdate(){this.props.open&&this.props.targetElement&&this.showToolTip({target:this.props.targetElement})}render(){if(this.props.children){const{children:e,...o}=this.props;let i=null;return n.createElement("div",{onMouseOver:h=>{i&&i.handleMouseOver(h)},onMouseOut:h=>{i&&i.handleMouseOut(h)}},n.createElement(a,{ref:h=>i=h,...o}),e)}if(this.props.open===!1)return null;const{targetElement:s}=this.state,t=this.getCurrentZIndex();return s&&this.state.title&&s.ownerDocument&&E.createPortal(n.createElement("div",{ref:e=>{if(!e)return;let o;if(this.props.onPosition){const i={element:e,targetElement:this.state.targetElement,mouseTop:this.top,mouseLeft:this.left,anchorElement:this.props.anchorElement,position:this.props.position,target:this,syntheticEvent:null,nativeEvent:null};o=this.props.onPosition.call(void 0,i)}else o=this.position(e);e.style.left=o.left+"px",e.style.top=o.top+"px"},className:r.classNames("k-animation-container","k-animation-container-fixed","k-animation-container-shown",this.props.className),style:{zIndex:t,...this.props.style},tabIndex:0},n.createElement("div",{className:"k-child-animation-container"},n.createElement("div",{id:this.props.id,role:"tooltip",className:r.classNames("k-tooltip",this.props.tooltipClassName),style:{position:"relative",...this.props.tooltipStyle}},n.createElement("div",{className:"k-tooltip-content"},this.props.content&&n.createElement(this.props.content,{title:this.state.title,target:this.state.targetElement})||this.state.title),this.props.showCallout&&n.createElement("div",{ref:e=>{e&&(e.className=this.calloutClassName(),this.props.position==="auto"&&(this.left<window.screen.availWidth/2?e.style.left=this.props.setCalloutOnPositionAuto||"25%":e.style.left=this.props.setCalloutOnPositionAuto||"75%"))}})))),this.props.appendTo?this.props.appendTo:s.ownerDocument.body)}showToolTip(s){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),s.target.hasChildNodes()&&s.target.childNodes.forEach(o=>{o.nodeName==="title"&&(s.target.titleExpando=o.innerHTML,o.remove())});const t=this.props.targetElement||s.target;let e=this.getTitle(t);if(!e.title){this.state.open&&this.onClose(s);return}e.element&&(e.element.titleExpando=e.title,e.element.title=""),this.willOpen=!0,this.props.openDelay?this.openTimeoutId=window.setTimeout(()=>{this.willOpen&&this.setState({targetElement:t,open:!0,title:e.title},this.setUpdateInterval)},this.props.openDelay):this.setState({targetElement:t,open:!0,title:e.title},this.setUpdateInterval),this.state.title!==e.title&&r.dispatchEvent(this.props.onOpen,s,this,void 0)}isVisible(s){return!this.props.filter||this.props.filter(s)}};a.propTypes={anchorElement:l.oneOf(["pointer","target"]),content:l.func,filter:l.func,openDelay:l.number,position:l.oneOf(["right","left","top","bottom","auto"]),updateInterval:l.number},a.defaultProps={anchorElement:"pointer",openDelay:400,position:"auto",showCallout:!0,parentTitle:!1},a.contextType=r.ZIndexContext;let u=a;exports.Tooltip=u;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),k=require("react-dom"),r=require("prop-types"),c=require("@progress/kendo-react-common"),d=require("./utils.js"),I=require("../package-metadata.js");function E(u){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(i,t,s.get?s:{enumerable:!0,get:()=>u[t]})}}return i.default=u,Object.freeze(i)}const l=E(y),C=E(k),b=100,h=class h extends l.PureComponent{constructor(i){super(i),this.context=0,this.state={targetElement:null,open:!1,title:""},this.top=0,this.left=0,this.willOpen=!1,this.handleMouseOut=t=>{const{targetElement:s}=this.state,e=s?s.ownerDocument:document;let a=e&&e.elementFromPoint(t.clientX,t.clientY);d.isTooltipElement(a)||this.props.open||(clearInterval(this.updateIntervalId),this.willOpen=!1,this.onClose(t))},this.compareTargets=t=>this.state.targetElement===t.nativeEvent.target,this.handleEscape=t=>{const s=this.compareTargets(t);this.state.open&&s&&this.onClose(t)},this.handleTargetItemClick=t=>{const s=this.compareTargets(t);if(this.state.open&&s){this.onClose(t);return}this.showToolTip(t)},this.handleKeyDown=(t,s)=>{const e=t.key;t.key==="Escape"?this.handleEscape(t):s.includes(e)&&this.handleMouseOver(t)},this.handleMouseOver=t=>{const s=t.target;!this.isVisible(s)||d.isTooltipElement(s)||s===this.state.targetElement||this.showToolTip(t)},this.handleBodyMousemove=t=>{this.top=t.clientY,this.left=t.clientX},this.onClose=t=>{c.dispatchEvent(this.props.onClose,t,this,void 0),this.setState({targetElement:null,open:!1,title:""})},this.setUpdateInterval=()=>{this.props.updateInterval&&(this.updateIntervalId=setInterval(this.onIntervalUpdate,this.props.updateInterval))},this.onIntervalUpdate=()=>{const t=this.state.targetElement;t&&(t.parentElement===null?this.onClose({target:t}):this.showToolTip({target:t}))},this.position=t=>{let s=d.getDomRect(this.state.targetElement);const e=d.getLeftPosition(this.left,t.offsetWidth,s,this.props.anchorElement,this.props.position),a=d.getTopPosition(this.top,s,t.offsetHeight,this.props.anchorElement,this.props.position);return{left:e,top:a}},this.getTitle=t=>{for(;t;){if(t.getAttribute("title")!==null||t.titleExpando)return{title:t.getAttribute("title")||t.titleExpando,element:t};t=this.props.parentTitle&&t.parentElement||null}return{title:"",element:t}},this.calloutClassName=()=>{switch(this.props.position){case"bottom":return"k-callout k-callout-n";case"left":return"k-callout k-callout-e";case"right":return"k-callout k-callout-w";case"top":return"k-callout k-callout-s";default:return this.top<window.innerHeight/2?"k-callout k-callout-n":"k-callout k-callout-s"}},this.getCurrentZIndex=()=>this.context?this.context:b,c.validatePackage(I.packageMetadata)}componentDidMount(){document&&document.body.addEventListener("mousemove",this.handleBodyMousemove)}componentWillUnmount(){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),document&&document.body.removeEventListener("mousemove",this.handleBodyMousemove)}componentDidUpdate(){this.props.open&&this.props.targetElement&&this.showToolTip({target:this.props.targetElement})}render(){if(this.props.children){const{children:s,showOption:e,...a}=this.props;let n=null;const f=(e==null?void 0:e.hover)!==void 0?e==null?void 0:e.hover:!0,v=(e==null?void 0:e.click)!==void 0?e==null?void 0:e.click:!1,T=(e==null?void 0:e.focus)!==void 0?e==null?void 0:e.focus:!1,p=(e==null?void 0:e.none)!==void 0?e==null?void 0:e.none:!1,g=((e==null?void 0:e.keys)!==void 0?e==null?void 0:e.keys:[]).map(o=>o==="Space"?" ":o);return l.createElement("div",{onMouseOver:o=>{n&&!p&&f&&n.handleMouseOver(o)},onMouseOut:o=>{n&&!p&&f&&n.handleMouseOut(o)},onClick:o=>{n&&!p&&v&&n.handleTargetItemClick(o)},onFocus:o=>{n&&!p&&T&&n.handleMouseOver(o)},onKeyDown:o=>{(n&&!p&&g.length>0||n&&!p&&o.key==="Escape")&&n.handleKeyDown(o,g)}},l.createElement(h,{ref:o=>n=o,...a}),s)}if(this.props.open===!1)return null;const{targetElement:i}=this.state,t=this.getCurrentZIndex();return i&&this.state.title&&i.ownerDocument&&C.createPortal(l.createElement("div",{ref:s=>{if(!s)return;let e;if(this.props.onPosition){const a={element:s,targetElement:this.state.targetElement,mouseTop:this.top,mouseLeft:this.left,anchorElement:this.props.anchorElement,position:this.props.position,target:this,syntheticEvent:null,nativeEvent:null};e=this.props.onPosition.call(void 0,a)}else e=this.position(s);s.style.left=e.left+"px",s.style.top=e.top+"px"},className:c.classNames("k-animation-container","k-animation-container-fixed","k-animation-container-shown",this.props.className),style:{zIndex:t,...this.props.style},tabIndex:0},l.createElement("div",{className:"k-child-animation-container"},l.createElement("div",{id:this.props.id,role:"tooltip",className:c.classNames("k-tooltip",this.props.tooltipClassName),style:{position:"relative",...this.props.tooltipStyle}},l.createElement("div",{className:"k-tooltip-content"},this.props.content&&l.createElement(this.props.content,{title:this.state.title,target:this.state.targetElement})||this.state.title),this.props.showCallout&&l.createElement("div",{ref:s=>{s&&(s.className=this.calloutClassName(),this.props.position==="auto"&&(this.left<window.screen.availWidth/2?s.style.left=this.props.setCalloutOnPositionAuto||"25%":s.style.left=this.props.setCalloutOnPositionAuto||"75%"))}})))),this.props.appendTo?this.props.appendTo:i.ownerDocument.body)}showToolTip(i){clearTimeout(this.openTimeoutId),clearInterval(this.updateIntervalId),i.target.hasChildNodes()&&i.target.childNodes.forEach(e=>{e.nodeName==="title"&&(i.target.titleExpando=e.innerHTML,e.remove())});const t=this.props.targetElement||i.target;let s=this.getTitle(t);if(!s.title){this.state.open&&this.onClose(i);return}s.element&&(s.element.titleExpando=s.title,s.element.title=""),this.willOpen=!0,this.props.openDelay?this.openTimeoutId=window.setTimeout(()=>{this.willOpen&&this.setState({targetElement:t,open:!0,title:s.title},this.setUpdateInterval)},this.props.openDelay):this.setState({targetElement:t,open:!0,title:s.title},this.setUpdateInterval),this.state.title!==s.title&&c.dispatchEvent(this.props.onOpen,i,this,void 0)}isVisible(i){return!this.props.filter||this.props.filter(i)}};h.propTypes={anchorElement:r.oneOf(["pointer","target"]),content:r.func,filter:r.func,openDelay:r.number,position:r.oneOf(["right","left","top","bottom","auto"]),updateInterval:r.number,showOption:r.object},h.defaultProps={anchorElement:"pointer",openDelay:400,position:"auto",showCallout:!0,parentTitle:!1},h.contextType=c.ZIndexContext;let m=h;exports.Tooltip=m;
@@ -6,29 +6,42 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as n from "react";
10
- import * as m from "react-dom";
11
- import l from "prop-types";
12
- import { dispatchEvent as p, validatePackage as d, ZIndexContext as f, classNames as h } from "@progress/kendo-react-common";
13
- import { isTooltipElement as u, getDomRect as g, getLeftPosition as E, getTopPosition as v } from "./utils.mjs";
14
- import { packageMetadata as I } from "../package-metadata.mjs";
15
- const T = 100, r = class r extends n.PureComponent {
16
- constructor(s) {
17
- super(s), this.context = 0, this.state = {
9
+ import * as l from "react";
10
+ import * as T from "react-dom";
11
+ import r from "prop-types";
12
+ import { dispatchEvent as d, validatePackage as y, ZIndexContext as I, classNames as m } from "@progress/kendo-react-common";
13
+ import { isTooltipElement as f, getDomRect as k, getLeftPosition as C, getTopPosition as x } from "./utils.mjs";
14
+ import { packageMetadata as D } from "../package-metadata.mjs";
15
+ const M = 100, h = class h extends l.PureComponent {
16
+ constructor(o) {
17
+ super(o), this.context = 0, this.state = {
18
18
  targetElement: null,
19
19
  open: !1,
20
20
  title: ""
21
21
  }, this.top = 0, this.left = 0, this.willOpen = !1, this.handleMouseOut = (t) => {
22
- const { targetElement: e } = this.state, o = e ? e.ownerDocument : document;
23
- let i = o && o.elementFromPoint(t.clientX, t.clientY);
24
- u(i) || this.props.open || (clearInterval(this.updateIntervalId), this.willOpen = !1, this.onClose(t));
22
+ const { targetElement: s } = this.state, e = s ? s.ownerDocument : document;
23
+ let a = e && e.elementFromPoint(t.clientX, t.clientY);
24
+ f(a) || this.props.open || (clearInterval(this.updateIntervalId), this.willOpen = !1, this.onClose(t));
25
+ }, this.compareTargets = (t) => this.state.targetElement === t.nativeEvent.target, this.handleEscape = (t) => {
26
+ const s = this.compareTargets(t);
27
+ this.state.open && s && this.onClose(t);
28
+ }, this.handleTargetItemClick = (t) => {
29
+ const s = this.compareTargets(t);
30
+ if (this.state.open && s) {
31
+ this.onClose(t);
32
+ return;
33
+ }
34
+ this.showToolTip(t);
35
+ }, this.handleKeyDown = (t, s) => {
36
+ const e = t.key;
37
+ t.key === "Escape" ? this.handleEscape(t) : s.includes(e) && this.handleMouseOver(t);
25
38
  }, this.handleMouseOver = (t) => {
26
- const e = t.target;
27
- !this.isVisible(e) || u(e) || e === this.state.targetElement || this.showToolTip(t);
39
+ const s = t.target;
40
+ !this.isVisible(s) || f(s) || s === this.state.targetElement || this.showToolTip(t);
28
41
  }, this.handleBodyMousemove = (t) => {
29
42
  this.top = t.clientY, this.left = t.clientX;
30
43
  }, this.onClose = (t) => {
31
- p(this.props.onClose, t, this, void 0), this.setState({ targetElement: null, open: !1, title: "" });
44
+ d(this.props.onClose, t, this, void 0), this.setState({ targetElement: null, open: !1, title: "" });
32
45
  }, this.setUpdateInterval = () => {
33
46
  this.props.updateInterval && (this.updateIntervalId = setInterval(
34
47
  this.onIntervalUpdate,
@@ -38,21 +51,21 @@ const T = 100, r = class r extends n.PureComponent {
38
51
  const t = this.state.targetElement;
39
52
  t && (t.parentElement === null ? this.onClose({ target: t }) : this.showToolTip({ target: t }));
40
53
  }, this.position = (t) => {
41
- let e = g(this.state.targetElement);
42
- const o = E(
54
+ let s = k(this.state.targetElement);
55
+ const e = C(
43
56
  this.left,
44
57
  t.offsetWidth,
45
- e,
58
+ s,
46
59
  this.props.anchorElement,
47
60
  this.props.position
48
- ), i = v(
61
+ ), a = x(
49
62
  this.top,
50
- e,
63
+ s,
51
64
  t.offsetHeight,
52
65
  this.props.anchorElement,
53
66
  this.props.position
54
67
  );
55
- return { left: o, top: i };
68
+ return { left: e, top: a };
56
69
  }, this.getTitle = (t) => {
57
70
  for (; t; ) {
58
71
  if (t.getAttribute("title") !== null || t.titleExpando)
@@ -73,7 +86,7 @@ const T = 100, r = class r extends n.PureComponent {
73
86
  default:
74
87
  return this.top < window.innerHeight / 2 ? "k-callout k-callout-n" : "k-callout k-callout-s";
75
88
  }
76
- }, this.getCurrentZIndex = () => this.context ? this.context : T, d(I);
89
+ }, this.getCurrentZIndex = () => this.context ? this.context : M, y(D);
77
90
  }
78
91
  /**
79
92
  * @hidden
@@ -98,36 +111,46 @@ const T = 100, r = class r extends n.PureComponent {
98
111
  */
99
112
  render() {
100
113
  if (this.props.children) {
101
- const { children: e, ...o } = this.props;
102
- let i = null;
103
- return /* @__PURE__ */ n.createElement(
114
+ const { children: s, showOption: e, ...a } = this.props;
115
+ let n = null;
116
+ const c = (e == null ? void 0 : e.hover) !== void 0 ? e == null ? void 0 : e.hover : !0, E = (e == null ? void 0 : e.click) !== void 0 ? e == null ? void 0 : e.click : !1, v = (e == null ? void 0 : e.focus) !== void 0 ? e == null ? void 0 : e.focus : !1, p = (e == null ? void 0 : e.none) !== void 0 ? e == null ? void 0 : e.none : !1, u = ((e == null ? void 0 : e.keys) !== void 0 ? e == null ? void 0 : e.keys : []).map((i) => i === "Space" ? " " : i);
117
+ return /* @__PURE__ */ l.createElement(
104
118
  "div",
105
119
  {
106
- onMouseOver: (a) => {
107
- i && i.handleMouseOver(a);
120
+ onMouseOver: (i) => {
121
+ n && !p && c && n.handleMouseOver(i);
122
+ },
123
+ onMouseOut: (i) => {
124
+ n && !p && c && n.handleMouseOut(i);
125
+ },
126
+ onClick: (i) => {
127
+ n && !p && E && n.handleTargetItemClick(i);
128
+ },
129
+ onFocus: (i) => {
130
+ n && !p && v && n.handleMouseOver(i);
108
131
  },
109
- onMouseOut: (a) => {
110
- i && i.handleMouseOut(a);
132
+ onKeyDown: (i) => {
133
+ (n && !p && u.length > 0 || n && !p && i.key === "Escape") && n.handleKeyDown(i, u);
111
134
  }
112
135
  },
113
- /* @__PURE__ */ n.createElement(r, { ref: (a) => i = a, ...o }),
114
- e
136
+ /* @__PURE__ */ l.createElement(h, { ref: (i) => n = i, ...a }),
137
+ s
115
138
  );
116
139
  }
117
140
  if (this.props.open === !1)
118
141
  return null;
119
- const { targetElement: s } = this.state, t = this.getCurrentZIndex();
120
- return s && this.state.title && s.ownerDocument && m.createPortal(
121
- /* @__PURE__ */ n.createElement(
142
+ const { targetElement: o } = this.state, t = this.getCurrentZIndex();
143
+ return o && this.state.title && o.ownerDocument && T.createPortal(
144
+ /* @__PURE__ */ l.createElement(
122
145
  "div",
123
146
  {
124
- ref: (e) => {
125
- if (!e)
147
+ ref: (s) => {
148
+ if (!s)
126
149
  return;
127
- let o;
150
+ let e;
128
151
  if (this.props.onPosition) {
129
- const i = {
130
- element: e,
152
+ const a = {
153
+ element: s,
131
154
  targetElement: this.state.targetElement,
132
155
  mouseTop: this.top,
133
156
  mouseLeft: this.left,
@@ -137,12 +160,12 @@ const T = 100, r = class r extends n.PureComponent {
137
160
  syntheticEvent: null,
138
161
  nativeEvent: null
139
162
  };
140
- o = this.props.onPosition.call(void 0, i);
163
+ e = this.props.onPosition.call(void 0, a);
141
164
  } else
142
- o = this.position(e);
143
- e.style.left = o.left + "px", e.style.top = o.top + "px";
165
+ e = this.position(s);
166
+ s.style.left = e.left + "px", s.style.top = e.top + "px";
144
167
  },
145
- className: h(
168
+ className: m(
146
169
  "k-animation-container",
147
170
  "k-animation-container-fixed",
148
171
  "k-animation-container-shown",
@@ -154,67 +177,68 @@ const T = 100, r = class r extends n.PureComponent {
154
177
  },
155
178
  tabIndex: 0
156
179
  },
157
- /* @__PURE__ */ n.createElement("div", { className: "k-child-animation-container" }, /* @__PURE__ */ n.createElement(
180
+ /* @__PURE__ */ l.createElement("div", { className: "k-child-animation-container" }, /* @__PURE__ */ l.createElement(
158
181
  "div",
159
182
  {
160
183
  id: this.props.id,
161
184
  role: "tooltip",
162
- className: h(
185
+ className: m(
163
186
  "k-tooltip",
164
187
  this.props.tooltipClassName
165
188
  ),
166
189
  style: { position: "relative", ...this.props.tooltipStyle }
167
190
  },
168
- /* @__PURE__ */ n.createElement("div", { className: "k-tooltip-content" }, this.props.content && /* @__PURE__ */ n.createElement(this.props.content, { title: this.state.title, target: this.state.targetElement }) || this.state.title),
169
- this.props.showCallout && /* @__PURE__ */ n.createElement(
191
+ /* @__PURE__ */ l.createElement("div", { className: "k-tooltip-content" }, this.props.content && /* @__PURE__ */ l.createElement(this.props.content, { title: this.state.title, target: this.state.targetElement }) || this.state.title),
192
+ this.props.showCallout && /* @__PURE__ */ l.createElement(
170
193
  "div",
171
194
  {
172
- ref: (e) => {
173
- e && (e.className = this.calloutClassName(), this.props.position === "auto" && (this.left < window.screen.availWidth / 2 ? e.style.left = this.props.setCalloutOnPositionAuto || "25%" : e.style.left = this.props.setCalloutOnPositionAuto || "75%"));
195
+ ref: (s) => {
196
+ s && (s.className = this.calloutClassName(), this.props.position === "auto" && (this.left < window.screen.availWidth / 2 ? s.style.left = this.props.setCalloutOnPositionAuto || "25%" : s.style.left = this.props.setCalloutOnPositionAuto || "75%"));
174
197
  }
175
198
  }
176
199
  )
177
200
  ))
178
201
  ),
179
- this.props.appendTo ? this.props.appendTo : s.ownerDocument.body
202
+ this.props.appendTo ? this.props.appendTo : o.ownerDocument.body
180
203
  );
181
204
  }
182
- showToolTip(s) {
183
- clearTimeout(this.openTimeoutId), clearInterval(this.updateIntervalId), s.target.hasChildNodes() && s.target.childNodes.forEach((o) => {
184
- o.nodeName === "title" && (s.target.titleExpando = o.innerHTML, o.remove());
205
+ showToolTip(o) {
206
+ clearTimeout(this.openTimeoutId), clearInterval(this.updateIntervalId), o.target.hasChildNodes() && o.target.childNodes.forEach((e) => {
207
+ e.nodeName === "title" && (o.target.titleExpando = e.innerHTML, e.remove());
185
208
  });
186
- const t = this.props.targetElement || s.target;
187
- let e = this.getTitle(t);
188
- if (!e.title) {
189
- this.state.open && this.onClose(s);
209
+ const t = this.props.targetElement || o.target;
210
+ let s = this.getTitle(t);
211
+ if (!s.title) {
212
+ this.state.open && this.onClose(o);
190
213
  return;
191
214
  }
192
- e.element && (e.element.titleExpando = e.title, e.element.title = ""), this.willOpen = !0, this.props.openDelay ? this.openTimeoutId = window.setTimeout(
215
+ s.element && (s.element.titleExpando = s.title, s.element.title = ""), this.willOpen = !0, this.props.openDelay ? this.openTimeoutId = window.setTimeout(
193
216
  () => {
194
- this.willOpen && this.setState({ targetElement: t, open: !0, title: e.title }, this.setUpdateInterval);
217
+ this.willOpen && this.setState({ targetElement: t, open: !0, title: s.title }, this.setUpdateInterval);
195
218
  },
196
219
  this.props.openDelay
197
- ) : this.setState({ targetElement: t, open: !0, title: e.title }, this.setUpdateInterval), this.state.title !== e.title && p(this.props.onOpen, s, this, void 0);
220
+ ) : this.setState({ targetElement: t, open: !0, title: s.title }, this.setUpdateInterval), this.state.title !== s.title && d(this.props.onOpen, o, this, void 0);
198
221
  }
199
- isVisible(s) {
200
- return !this.props.filter || this.props.filter(s);
222
+ isVisible(o) {
223
+ return !this.props.filter || this.props.filter(o);
201
224
  }
202
225
  };
203
- r.propTypes = {
204
- anchorElement: l.oneOf(["pointer", "target"]),
205
- content: l.func,
206
- filter: l.func,
207
- openDelay: l.number,
208
- position: l.oneOf(["right", "left", "top", "bottom", "auto"]),
209
- updateInterval: l.number
210
- }, r.defaultProps = {
226
+ h.propTypes = {
227
+ anchorElement: r.oneOf(["pointer", "target"]),
228
+ content: r.func,
229
+ filter: r.func,
230
+ openDelay: r.number,
231
+ position: r.oneOf(["right", "left", "top", "bottom", "auto"]),
232
+ updateInterval: r.number,
233
+ showOption: r.object
234
+ }, h.defaultProps = {
211
235
  anchorElement: "pointer",
212
236
  openDelay: 400,
213
237
  position: "auto",
214
238
  showCallout: !0,
215
239
  parentTitle: !1
216
- }, r.contextType = f;
217
- let c = r;
240
+ }, h.contextType = I;
241
+ let g = h;
218
242
  export {
219
- c as Tooltip
243
+ g as Tooltip
220
244
  };