@progress/kendo-react-popup
Advanced tools
Comparing version 8.3.0-develop.9 to 8.3.0-develop.10
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
!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-popup-common")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-common","@progress/kendo-popup-common"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).KendoReactPopup={},t.React,t.ReactDOM,t.PropTypes,t.KendoReactCommon,t.KendoPopupCommon)}(this,(function(t,e,o,n,i,s){"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 p=r(e),l=r(o);const a=(t,e,o)=>{t.style.transitionDuration="",e&&t.classList.remove(...e.split(" ")),e&&t.classList.remove(...o.split(" "))},c="undefined"!=typeof window&&/Firefox/.test(window.navigator.userAgent),u={name:"@progress/kendo-react-popup",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"};function h(t,e){if(t===e)return!0;if(!!t!=!!e)return!1;const o=Object.getOwnPropertyNames(t),n=Object.getOwnPropertyNames(e);if(o.length!==n.length)return!1;for(let n=0;n<o.length;n++){let i=o[n];if(t[i]!==e[i])return!1}return!0}const d=class extends p.Component{constructor(t){super(t),this.context=0,this.state={current:"hidden",previous:"hidden",props:{}},this._popup=null,this.show=t=>{this.setPosition(t),this.animate(t.firstChild,"enter",this.onOpened),this.setState({current:"shown",previous:this.state.current})},this.setPosition=t=>{let{anchorAlign:e,popupAlign:o,collision:n,offset:i,anchor:r,margin:p,scale:l,positionMode:a}=this.props;const{width:c,height:u}=t.style;t.style.width=t.offsetWidth+"px",t.style.height=t.offsetHeight+"px";const h=s.alignElement({anchor:r,anchorAlign:e,element:t,elementAlign:o,offset:i,margin:p,positionMode:a,scale:l}),d=s.positionElement({anchor:r,anchorAlign:e,element:t,elementAlign:o,collisions:n,currentLocation:h,margin:this.props.margin});if(t.style.top=d.offset.top+"px",t.style.left=d.offset.left+"px",t.style.width=c,t.style.height=u,this._collisions={fit:d.fit,fitted:d.fitted,flip:d.flip,flipped:d.flipped},this.props.onPosition){const t={target:this,flipped:d.flipped,fitted:d.fitted};this.props.onPosition.call(void 0,t)}},this.onOpened=()=>{const t=this._popup;if(t){if(this.props.show){const{unstyled:e}=this.props,o=e&&e.uPopup;t.classList.add(...i.classNames(i.uPopup.animationContainerShown({c:o})).split(" ").filter((t=>t)))}this.attachRepositionHandlers(t),this.props.onOpen&&this.props.onOpen.call(void 0,{target:this})}},this.animate=(t,e,o)=>{if(!this.props.popupAlign)return;let n;const{horizontal:s,vertical:r}=this.props.popupAlign;n="left"===s&&"center"===r?"right":"right"===s&&"center"===r?"left":"top"===r?"down":"up";this._collisions&&this._collisions.flipped&&(n={down:"up",up:"down",left:"right",right:"left"}[n]);const{unstyled:p}=this.props,l=p&&p.uPopup;((t,e,o,n,s,r)=>{if(0===o)return s();const p=i.classNames(i.uPopup.slide({direction:e,type:n,c:r})),l=i.classNames(i.uPopup.slideActive({direction:e,type:n,c:r})),u=e=>{e.target===t&&(t.removeEventListener("transitionend",u),a(t,p,l),t.style.display="exit"===n?"none":"",s())};t.addEventListener("transitionend",u);const h=t.ownerDocument;if(!h)return;const d=h.defaultView;if(!d)return;const f=()=>{a(t,p,l),p&&t.classList.add(...p.split(" ").filter((t=>t))),d.requestAnimationFrame((()=>{t.style.transitionDuration=o+"ms",t.classList.add(...l.split(" ").filter((t=>t)))}))};c?d.requestAnimationFrame(f):f()})(t,n,this.animationDuration[e],e,o,l)},this.onClosing=t=>{if(!this.props.show){const{unstyled:e}=this.props,o=e&&e.uPopup;t.classList.remove(...i.classNames(i.uPopup.animationContainerShown({c:o})).split(" ").filter((t=>t)))}this.detachRepositionHandlers()},this.onClosed=()=>{"hiding"===this.state.current&&"shown"===this.state.previous&&this.setState({current:"hidden",previous:this.state.current}),this.props.onClose&&this.props.onClose.call(void 0,{target:this})},this.getCurrentZIndex=()=>this.context?this.context+1:100,i.validatePackage(u),this.reposition=function(t,e,o={}){let n,i,s,r,p=0;o=o||{};const l=function(){p=!1===o.leading?0:(new Date).getTime(),n=void 0,r=t.apply(i,s),n||(i=s=null)};return function(){const a=(new Date).getTime();!p&&!1===o.leading&&(p=a);const c=e-(a-p);return i=void 0,s=arguments,c<=0||c>e?(n&&(clearTimeout(n),n=void 0),p=a,r=t.apply(i,s),n||(i=s=null)):!n&&!1!==o.trailing&&(n=window.setTimeout(l,c)),r}}(this.reposition.bind(this),16.666666666666668)}get element(){return this._popup}static getDerivedStateFromProps(t,e){const{show:o,anchor:n,anchorAlign:i,appendTo:s,collision:r,popupAlign:p,className:l,popupClass:a,style:c,offset:u,contentKey:d}=t,f={...e,props:{show:o,anchor:n,anchorAlign:i,appendTo:s,collision:r,popupAlign:p,className:l,popupClass:a,style:c,offset:u,contentKey:d}};return t.show?"hidden"===e.current||"hiding"===e.current?{...f,current:"showing",previous:e.current}:"showing"===e.current?{...f,current:"shown",previous:e.current}:"shown"!==e.current||h(u,e.props.offset)&&h(i,e.props.anchorAlign)&&h(s,e.props.appendTo)&&h(r,e.props.collision)&&h(p,e.props.popupAlign)&&h(c,e.props.style)&&n===e.props.anchor&&a===e.props.popupClass&&l===e.props.className?f:{...f,current:"reposition",previous:e.current}:"hiding"===e.current||"hidden"===e.current?{...f,current:"hidden",previous:e.current}:{...f,current:"hiding",previous:e.current}}componentDidUpdate(t){"showing"===this.state.current&&this._popup?this.show(this._popup):"hiding"===this.state.current&&this._popup?(this.onClosing(this._popup),this.animate(this._popup.firstChild,"exit",this.onClosed)):"reposition"===this.state.current&&"shown"===this.state.previous?setTimeout((()=>{this.setState({current:"shown",previous:this.state.current})}),0):"shown"===this.state.current&&t.contentKey!==this.props.contentKey&&this._popup&&this.setPosition(this._popup)}componentDidMount(){"showing"===this.state.current&&this._popup&&this.show(this._popup)}componentWillUnmount(){this.detachRepositionHandlers()}render(){const{children:t,className:e,popupClass:o,unstyled:n,show:s,id:r,positionMode:a}=this.props,c=n&&n.uPopup,u=this.props.appendTo?this.props.appendTo:i.canUseDOM?this.props.anchor&&this.props.anchor.ownerDocument?this.props.anchor.ownerDocument.body:document.body:void 0;"reposition"===this.state.current&&"shown"===this.state.previous&&this._popup&&this.setPosition(this._popup);const h=Object.assign({},{position:a,top:0,left:-1e4},this.props.style||{}),d="hiding"===this.state.current;if((s||d)&&u){const n=this.getCurrentZIndex(),s=p.createElement(i.ZIndexContext.Provider,{value:n},p.createElement("div",{onKeyDown:this.props.onKeyDown,className:i.classNames(i.uPopup.animationContainer({c:c}),e),id:r,ref:t=>this._popup=t,style:{zIndex:n,...h}},p.createElement("div",{className:i.classNames(i.uPopup.animationChild({c:c})),style:{transitionDelay:"0ms"}},p.createElement("div",{role:this.props.role,className:i.classNames(i.uPopup.popup({c:c}),o)},t))));return null!==this.props.appendTo?l.createPortal(s,u):s}return null}get animationDuration(){const t=this.props.animate;let e=0,o=0;return t&&(!0===t?e=o=300:(e=t.openDuration||0,o=t.closeDuration||0)),{enter:e,exit:o}}attachRepositionHandlers(t){this.detachRepositionHandlers(),this._scrollableParents=s.domUtils.scrollableParents(this.props.anchor||t),this._scrollableParents&&this._scrollableParents.map((t=>t.addEventListener("scroll",this.reposition))),window.addEventListener("resize",this.reposition)}detachRepositionHandlers(){this._scrollableParents&&(this._scrollableParents.map((t=>t.removeEventListener("scroll",this.reposition))),this._scrollableParents=void 0),window.removeEventListener("resize",this.reposition)}reposition(){this.setState({current:"reposition",previous:this.state.current})}};d.propTypes={anchor:function(t){const e=t.anchor;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. 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 Popup`. Validation failed."):null},className:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),id:n.string,popupClass:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),collision:n.shape({horizontal:n.oneOf([s.Collision.fit,s.Collision.flip,s.Collision.none]),vertical:n.oneOf([s.Collision.fit,s.Collision.flip,s.Collision.none])}),anchorAlign:n.shape({horizontal:n.oneOf([s.AlignPoint.left,s.AlignPoint.center,s.AlignPoint.right]),vertical:n.oneOf([s.AlignPoint.top,s.AlignPoint.center,s.AlignPoint.bottom])}),popupAlign:n.shape({horizontal:n.oneOf([s.AlignPoint.left,s.AlignPoint.center,s.AlignPoint.right]),vertical:n.oneOf([s.AlignPoint.top,s.AlignPoint.center,s.AlignPoint.bottom])}),offset:n.shape({left:n.number,top:n.number}),children:n.oneOfType([n.element,n.node]),show:n.bool,animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),margin:n.shape({horizontal:n.number,vertical:n.number}),positionMode:n.oneOf(["fixed","absolute"]),scale:n.number,style:n.object,onClose:n.func,onPosition:n.func,onOpen:n.func,onKeyPress:n.func},d.defaultProps={collision:{horizontal:s.Collision.fit,vertical:s.Collision.flip},anchorAlign:{horizontal:s.AlignPoint.left,vertical:s.AlignPoint.bottom},popupAlign:{horizontal:s.AlignPoint.left,vertical:s.AlignPoint.top},offset:{left:-1e3,top:0},animate:!0,show:!1,margin:{horizontal:0,vertical:0},positionMode:"absolute"},d.contextType=i.ZIndexContext,d.displayName="PopupComponent";let f=d;const m=p.createContext((t=>t)),g=p.forwardRef(((t,e)=>{const o=p.useContext(m),n=i.useUnstyled(),s=o.call(void 0,t);return p.createElement(f,{ref:e,unstyled:n,...s})}));g.displayName="Popup",t.Popup=g,t.PopupPropsContext=m,t.PopupWithoutContext=f})); | ||
!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-popup-common")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-common","@progress/kendo-popup-common"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).KendoReactPopup={},t.React,t.ReactDOM,t.PropTypes,t.KendoReactCommon,t.KendoPopupCommon)}(this,(function(t,e,o,n,i,s){"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 p=r(e),l=r(o);const a=(t,e,o)=>{t.style.transitionDuration="",e&&t.classList.remove(...e.split(" ")),e&&t.classList.remove(...o.split(" "))},c="undefined"!=typeof window&&/Firefox/.test(window.navigator.userAgent),u={name:"@progress/kendo-react-popup",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"};function h(t,e){if(t===e)return!0;if(!!t!=!!e)return!1;const o=Object.getOwnPropertyNames(t),n=Object.getOwnPropertyNames(e);if(o.length!==n.length)return!1;for(let n=0;n<o.length;n++){let i=o[n];if(t[i]!==e[i])return!1}return!0}const d=class extends p.Component{constructor(t){super(t),this.context=0,this.state={current:"hidden",previous:"hidden",props:{}},this._popup=null,this.show=t=>{null==window||window.addEventListener("mousedown",this.handleMouseDown),this.setPosition(t),this.animate(t.firstChild,"enter",this.onOpened),this.setState({current:"shown",previous:this.state.current})},this.setPosition=t=>{let{anchorAlign:e,popupAlign:o,collision:n,offset:i,anchor:r,margin:p,scale:l,positionMode:a}=this.props;const{width:c,height:u}=t.style;t.style.width=t.offsetWidth+"px",t.style.height=t.offsetHeight+"px";const h=s.alignElement({anchor:r,anchorAlign:e,element:t,elementAlign:o,offset:i,margin:p,positionMode:a,scale:l}),d=s.positionElement({anchor:r,anchorAlign:e,element:t,elementAlign:o,collisions:n,currentLocation:h,margin:this.props.margin});if(t.style.top=d.offset.top+"px",t.style.left=d.offset.left+"px",t.style.width=c,t.style.height=u,this._collisions={fit:d.fit,fitted:d.fitted,flip:d.flip,flipped:d.flipped},this.props.onPosition){const t={target:this,flipped:d.flipped,fitted:d.fitted};this.props.onPosition.call(void 0,t)}},this.onOpened=()=>{const t=this._popup;if(t){if(this.props.show){const{unstyled:e}=this.props,o=e&&e.uPopup;t.classList.add(...i.classNames(i.uPopup.animationContainerShown({c:o})).split(" ").filter((t=>t)))}this.attachRepositionHandlers(t),this.props.onOpen&&this.props.onOpen.call(void 0,{target:this})}},this.animate=(t,e,o)=>{if(!this.props.popupAlign)return;let n;const{horizontal:s,vertical:r}=this.props.popupAlign;n="left"===s&&"center"===r?"right":"right"===s&&"center"===r?"left":"top"===r?"down":"up";this._collisions&&this._collisions.flipped&&(n={down:"up",up:"down",left:"right",right:"left"}[n]);const{unstyled:p}=this.props,l=p&&p.uPopup;((t,e,o,n,s,r)=>{if(0===o)return s();const p=i.classNames(i.uPopup.slide({direction:e,type:n,c:r})),l=i.classNames(i.uPopup.slideActive({direction:e,type:n,c:r})),u=e=>{e.target===t&&(t.removeEventListener("transitionend",u),a(t,p,l),t.style.display="exit"===n?"none":"",s())};t.addEventListener("transitionend",u);const h=t.ownerDocument;if(!h)return;const d=h.defaultView;if(!d)return;const f=()=>{a(t,p,l),p&&t.classList.add(...p.split(" ").filter((t=>t))),d.requestAnimationFrame((()=>{t.style.transitionDuration=o+"ms",t.classList.add(...l.split(" ").filter((t=>t)))}))};c?d.requestAnimationFrame(f):f()})(t,n,this.animationDuration[e],e,o,l)},this.handleMouseDown=t=>{var e,o;const n=null===(null==(e=null==t?void 0:t.target)?void 0:e.closest(".k-animation-container")),i=(null==(o=this.props.anchor)?void 0:o.contains(null==t?void 0:t.target))||!1;if(n){if(this.props.onMouseDownOutside){const e={target:this,event:t,state:this.state,isAnchorClicked:i};this.props.onMouseDownOutside.call(void 0,e)}null==window||window.removeEventListener("mousedown",this.handleMouseDown)}},this.onClosing=t=>{if(!this.props.show){const{unstyled:e}=this.props,o=e&&e.uPopup;t.classList.remove(...i.classNames(i.uPopup.animationContainerShown({c:o})).split(" ").filter((t=>t)))}this.detachRepositionHandlers()},this.onClosed=()=>{"hiding"===this.state.current&&"shown"===this.state.previous&&this.setState({current:"hidden",previous:this.state.current}),this.props.onClose&&this.props.onClose.call(void 0,{target:this})},this.getCurrentZIndex=()=>this.context?this.context+1:100,i.validatePackage(u),this.reposition=function(t,e,o={}){let n,i,s,r,p=0;o=o||{};const l=function(){p=!1===o.leading?0:(new Date).getTime(),n=void 0,r=t.apply(i,s),n||(i=s=null)};return function(){const a=(new Date).getTime();!p&&!1===o.leading&&(p=a);const c=e-(a-p);return i=void 0,s=arguments,c<=0||c>e?(n&&(clearTimeout(n),n=void 0),p=a,r=t.apply(i,s),n||(i=s=null)):!n&&!1!==o.trailing&&(n=window.setTimeout(l,c)),r}}(this.reposition.bind(this),16.666666666666668)}get element(){return this._popup}static getDerivedStateFromProps(t,e){const{show:o,anchor:n,anchorAlign:i,appendTo:s,collision:r,popupAlign:p,className:l,popupClass:a,style:c,offset:u,contentKey:d}=t,f={...e,props:{show:o,anchor:n,anchorAlign:i,appendTo:s,collision:r,popupAlign:p,className:l,popupClass:a,style:c,offset:u,contentKey:d}};return t.show?"hidden"===e.current||"hiding"===e.current?{...f,current:"showing",previous:e.current}:"showing"===e.current?{...f,current:"shown",previous:e.current}:"shown"!==e.current||h(u,e.props.offset)&&h(i,e.props.anchorAlign)&&h(s,e.props.appendTo)&&h(r,e.props.collision)&&h(p,e.props.popupAlign)&&h(c,e.props.style)&&n===e.props.anchor&&a===e.props.popupClass&&l===e.props.className?f:{...f,current:"reposition",previous:e.current}:"hiding"===e.current||"hidden"===e.current?{...f,current:"hidden",previous:e.current}:{...f,current:"hiding",previous:e.current}}componentDidUpdate(t){"showing"===this.state.current&&this._popup?this.show(this._popup):"hiding"===this.state.current&&this._popup?(this.onClosing(this._popup),this.animate(this._popup.firstChild,"exit",this.onClosed)):"reposition"===this.state.current&&"shown"===this.state.previous?setTimeout((()=>{this.setState({current:"shown",previous:this.state.current})}),0):"shown"===this.state.current&&t.contentKey!==this.props.contentKey&&this._popup&&this.setPosition(this._popup)}componentDidMount(){"showing"===this.state.current&&this._popup&&this.show(this._popup)}componentWillUnmount(){this.detachRepositionHandlers()}render(){const{children:t,className:e,popupClass:o,unstyled:n,show:s,id:r,positionMode:a}=this.props,c=n&&n.uPopup,u=this.props.appendTo?this.props.appendTo:i.canUseDOM?this.props.anchor&&this.props.anchor.ownerDocument?this.props.anchor.ownerDocument.body:document.body:void 0;"reposition"===this.state.current&&"shown"===this.state.previous&&this._popup&&this.setPosition(this._popup);const h=Object.assign({},{position:a,top:0,left:-1e4},this.props.style||{}),d="hiding"===this.state.current;if((s||d)&&u){const n=this.getCurrentZIndex(),s=p.createElement(i.ZIndexContext.Provider,{value:n},p.createElement("div",{onKeyDown:this.props.onKeyDown,className:i.classNames(i.uPopup.animationContainer({c:c}),e),id:r,ref:t=>this._popup=t,style:{zIndex:n,...h}},p.createElement("div",{className:i.classNames(i.uPopup.animationChild({c:c})),style:{transitionDelay:"0ms"}},p.createElement("div",{role:this.props.role,className:i.classNames(i.uPopup.popup({c:c}),o)},t))));return null!==this.props.appendTo?l.createPortal(s,u):s}return null}get animationDuration(){const t=this.props.animate;let e=0,o=0;return t&&(!0===t?e=o=300:(e=t.openDuration||0,o=t.closeDuration||0)),{enter:e,exit:o}}attachRepositionHandlers(t){this.detachRepositionHandlers(),this._scrollableParents=s.domUtils.scrollableParents(this.props.anchor||t),this._scrollableParents&&this._scrollableParents.map((t=>t.addEventListener("scroll",this.reposition))),window.addEventListener("resize",this.reposition)}detachRepositionHandlers(){this._scrollableParents&&(this._scrollableParents.map((t=>t.removeEventListener("scroll",this.reposition))),this._scrollableParents=void 0),window.removeEventListener("resize",this.reposition)}reposition(){this.setState({current:"reposition",previous:this.state.current})}};d.propTypes={anchor:function(t){const e=t.anchor;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. 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 Popup`. Validation failed."):null},className:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),id:n.string,popupClass:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),collision:n.shape({horizontal:n.oneOf([s.Collision.fit,s.Collision.flip,s.Collision.none]),vertical:n.oneOf([s.Collision.fit,s.Collision.flip,s.Collision.none])}),anchorAlign:n.shape({horizontal:n.oneOf([s.AlignPoint.left,s.AlignPoint.center,s.AlignPoint.right]),vertical:n.oneOf([s.AlignPoint.top,s.AlignPoint.center,s.AlignPoint.bottom])}),popupAlign:n.shape({horizontal:n.oneOf([s.AlignPoint.left,s.AlignPoint.center,s.AlignPoint.right]),vertical:n.oneOf([s.AlignPoint.top,s.AlignPoint.center,s.AlignPoint.bottom])}),offset:n.shape({left:n.number,top:n.number}),children:n.oneOfType([n.element,n.node]),show:n.bool,animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),margin:n.shape({horizontal:n.number,vertical:n.number}),positionMode:n.oneOf(["fixed","absolute"]),scale:n.number,style:n.object,onClose:n.func,onPosition:n.func,onOpen:n.func,onKeyPress:n.func,onMouseDownOutside:n.func},d.defaultProps={collision:{horizontal:s.Collision.fit,vertical:s.Collision.flip},anchorAlign:{horizontal:s.AlignPoint.left,vertical:s.AlignPoint.bottom},popupAlign:{horizontal:s.AlignPoint.left,vertical:s.AlignPoint.top},offset:{left:-1e3,top:0},animate:!0,show:!1,margin:{horizontal:0,vertical:0},positionMode:"absolute"},d.contextType=i.ZIndexContext,d.displayName="PopupComponent";let f=d;const m=p.createContext((t=>t)),g=p.forwardRef(((t,e)=>{const o=p.useContext(m),n=i.useUnstyled(),s=o.call(void 0,t);return p.createElement(f,{ref:e,unstyled:n,...s})}));g.displayName="Popup",t.Popup=g,t.PopupPropsContext=m,t.PopupWithoutContext=f})); |
@@ -84,2 +84,24 @@ /** | ||
/** | ||
* Represents the object of the `MouseDownOutside` Popup event. | ||
*/ | ||
export declare interface MouseDownOutsideEvent { | ||
/** | ||
* An event target. | ||
*/ | ||
target: Popup; | ||
/** | ||
* The event object. | ||
*/ | ||
event: MouseEvent; | ||
/** | ||
* The state of the Popup. | ||
*/ | ||
state: PopupState; | ||
/** | ||
* Indicates if the MouseDown event is triggered over the anchor of the Popup. | ||
*/ | ||
isAnchorClicked: boolean; | ||
} | ||
/** | ||
* The offset position of the Popup. | ||
@@ -232,2 +254,6 @@ */ | ||
/** | ||
* Fires when the mousedown event is triggered outside the Popup. | ||
*/ | ||
onMouseDownOutside?: (event: MouseDownOutsideEvent) => void; | ||
/** | ||
* Controls the Popup visibility ([see example]({% slug hidden_popup %})). Defaults to `false`. | ||
@@ -344,2 +370,3 @@ */ | ||
onKeyPress: PropTypes.Requireable<(...args: any[]) => any>; | ||
onMouseDownOutside: PropTypes.Requireable<(...args: any[]) => any>; | ||
}; | ||
@@ -441,2 +468,3 @@ /** | ||
private animate; | ||
private handleMouseDown; | ||
private onClosing; | ||
@@ -454,3 +482,3 @@ private onClosed; | ||
*/ | ||
declare interface PositionEvent { | ||
export declare interface PositionEvent { | ||
/** | ||
@@ -457,0 +485,0 @@ * An event target. |
{ | ||
"name": "@progress/kendo-react-popup", | ||
"version": "8.3.0-develop.9", | ||
"version": "8.3.0-develop.10", | ||
"description": "React Popup positions a piece of content next to a specific anchor component. KendoReact Popup package", | ||
@@ -27,3 +27,3 @@ "author": "Progress", | ||
"@progress/kendo-popup-common": "^1.9.0", | ||
"@progress/kendo-react-common": "8.3.0-develop.9", | ||
"@progress/kendo-react-common": "8.3.0-develop.10", | ||
"react": "^16.8.2 || ^17.0.0 || ^18.0.0", | ||
@@ -30,0 +30,0 @@ "react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0" |
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react"),T=require("react-dom"),e=require("prop-types"),D=require("./animation.js"),l=require("@progress/kendo-react-common"),n=require("@progress/kendo-popup-common"),O=require("./util.js"),E=require("./package-metadata.js");function A(c){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(i,t,o.get?o:{enumerable:!0,get:()=>c[t]})}}return i.default=c,Object.freeze(i)}const w=A(_),N=A(T),x=100,R=1;function v(c,i){if(c===i)return!0;if(!!c!=!!i)return!1;const t=Object.getOwnPropertyNames(c),o=Object.getOwnPropertyNames(i);if(t.length!==o.length)return!1;for(let r=0;r<t.length;r++){let s=t[r];if(c[s]!==i[s])return!1}return!0}const S={left:-1e3,top:0},y=class y extends w.Component{constructor(i){super(i),this.context=0,this.state={current:"hidden",previous:"hidden",props:{}},this._popup=null,this.show=t=>{this.setPosition(t),this.animate(t.firstChild,"enter",this.onOpened),this.setState({current:"shown",previous:this.state.current})},this.setPosition=t=>{let{anchorAlign:o,popupAlign:r,collision:s,offset:d,anchor:a,margin:h,scale:u,positionMode:f}=this.props;const{width:g,height:m}=t.style;t.style.width=t.offsetWidth+"px",t.style.height=t.offsetHeight+"px";const P=n.alignElement({anchor:a,anchorAlign:o,element:t,elementAlign:r,offset:d,margin:h,positionMode:f,scale:u}),p=n.positionElement({anchor:a,anchorAlign:o,element:t,elementAlign:r,collisions:s,currentLocation:P,margin:this.props.margin});if(t.style.top=p.offset.top+"px",t.style.left=p.offset.left+"px",t.style.width=g,t.style.height=m,this._collisions={fit:p.fit,fitted:p.fitted,flip:p.flip,flipped:p.flipped},this.props.onPosition){const C={target:this,flipped:p.flipped,fitted:p.fitted};this.props.onPosition.call(void 0,C)}},this.onOpened=()=>{const t=this._popup;if(t){if(this.props.show){const{unstyled:o}=this.props,r=o&&o.uPopup;t.classList.add(...l.classNames(l.uPopup.animationContainerShown({c:r})).split(" ").filter(s=>s))}this.attachRepositionHandlers(t),this.props.onOpen&&this.props.onOpen.call(void 0,{target:this})}},this.animate=(t,o,r)=>{if(!this.props.popupAlign)return;let s;const{horizontal:d,vertical:a}=this.props.popupAlign;d==="left"&&a==="center"?s="right":d==="right"&&a==="center"?s="left":a==="top"?s="down":s="up";const h={down:"up",up:"down",left:"right",right:"left"};this._collisions&&this._collisions.flipped&&(s=h[s]);const{unstyled:u}=this.props,f=u&&u.uPopup;D.slide(t,s,this.animationDuration[o],o,r,f)},this.onClosing=t=>{if(!this.props.show){const{unstyled:o}=this.props,r=o&&o.uPopup;t.classList.remove(...l.classNames(l.uPopup.animationContainerShown({c:r})).split(" ").filter(s=>s))}this.detachRepositionHandlers()},this.onClosed=()=>{this.state.current==="hiding"&&this.state.previous==="shown"&&this.setState({current:"hidden",previous:this.state.current}),this.props.onClose&&this.props.onClose.call(void 0,{target:this})},this.getCurrentZIndex=()=>this.context?this.context+R:x,l.validatePackage(E.packageMetadata),this.reposition=O.throttle(this.reposition.bind(this),O.FRAME_DURATION)}get element(){return this._popup}static getDerivedStateFromProps(i,t){const{show:o,anchor:r,anchorAlign:s,appendTo:d,collision:a,popupAlign:h,className:u,popupClass:f,style:g,offset:m,contentKey:P}=i,p={...t,props:{show:o,anchor:r,anchorAlign:s,appendTo:d,collision:a,popupAlign:h,className:u,popupClass:f,style:g,offset:m,contentKey:P}};return i.show?t.current==="hidden"||t.current==="hiding"?{...p,current:"showing",previous:t.current}:t.current==="showing"?{...p,current:"shown",previous:t.current}:t.current==="shown"&&(!v(m,t.props.offset)||!v(s,t.props.anchorAlign)||!v(d,t.props.appendTo)||!v(a,t.props.collision)||!v(h,t.props.popupAlign)||!v(g,t.props.style)||r!==t.props.anchor||f!==t.props.popupClass||u!==t.props.className)?{...p,current:"reposition",previous:t.current}:p:t.current==="hiding"||t.current==="hidden"?{...p,current:"hidden",previous:t.current}:{...p,current:"hiding",previous:t.current}}componentDidUpdate(i){this.state.current==="showing"&&this._popup?this.show(this._popup):this.state.current==="hiding"&&this._popup?(this.onClosing(this._popup),this.animate(this._popup.firstChild,"exit",this.onClosed)):this.state.current==="reposition"&&this.state.previous==="shown"?setTimeout(()=>{this.setState({current:"shown",previous:this.state.current})},0):this.state.current==="shown"&&i.contentKey!==this.props.contentKey&&this._popup&&this.setPosition(this._popup)}componentDidMount(){this.state.current==="showing"&&this._popup&&this.show(this._popup)}componentWillUnmount(){this.detachRepositionHandlers()}render(){const{children:i,className:t,popupClass:o,unstyled:r,show:s,id:d,positionMode:a}=this.props,h=r&&r.uPopup,u=this.props.appendTo?this.props.appendTo:l.canUseDOM?this.props.anchor&&this.props.anchor.ownerDocument?this.props.anchor.ownerDocument.body:document.body:void 0;this.state.current==="reposition"&&this.state.previous==="shown"&&this._popup&&this.setPosition(this._popup);const f=Object.assign({},{position:a,top:0,left:-1e4},this.props.style||{}),g=this.state.current==="hiding";if((s||g)&&u){const m=this.getCurrentZIndex(),P=w.createElement(l.ZIndexContext.Provider,{value:m},w.createElement("div",{onKeyDown:this.props.onKeyDown,className:l.classNames(l.uPopup.animationContainer({c:h}),t),id:d,ref:p=>this._popup=p,style:{zIndex:m,...f}},w.createElement("div",{className:l.classNames(l.uPopup.animationChild({c:h})),style:{transitionDelay:"0ms"}},w.createElement("div",{role:this.props.role,className:l.classNames(l.uPopup.popup({c:h}),o)},i))));return this.props.appendTo!==null?N.createPortal(P,u):P}return null}get animationDuration(){const i=this.props.animate;let t=0,o=0;return i&&(i===!0?t=o=300:(t=i.openDuration||0,o=i.closeDuration||0)),{enter:t,exit:o}}attachRepositionHandlers(i){this.detachRepositionHandlers(),this._scrollableParents=n.domUtils.scrollableParents(this.props.anchor||i),this._scrollableParents&&this._scrollableParents.map(t=>t.addEventListener("scroll",this.reposition)),window.addEventListener("resize",this.reposition)}detachRepositionHandlers(){this._scrollableParents&&(this._scrollableParents.map(i=>i.removeEventListener("scroll",this.reposition)),this._scrollableParents=void 0),window.removeEventListener("resize",this.reposition)}reposition(){this.setState({current:"reposition",previous:this.state.current})}};y.propTypes={anchor:function(i){const t=i.anchor;return t&&typeof t.nodeType!="number"?new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. Validation failed."):null},appendTo:function(i){const t=i.appendTo;return t&&typeof t.nodeType!="number"?new Error("Invalid prop `appendTo` supplied to `Kendo React Popup`. Validation failed."):null},className:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),id:e.string,popupClass:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),collision:e.shape({horizontal:e.oneOf([n.Collision.fit,n.Collision.flip,n.Collision.none]),vertical:e.oneOf([n.Collision.fit,n.Collision.flip,n.Collision.none])}),anchorAlign:e.shape({horizontal:e.oneOf([n.AlignPoint.left,n.AlignPoint.center,n.AlignPoint.right]),vertical:e.oneOf([n.AlignPoint.top,n.AlignPoint.center,n.AlignPoint.bottom])}),popupAlign:e.shape({horizontal:e.oneOf([n.AlignPoint.left,n.AlignPoint.center,n.AlignPoint.right]),vertical:e.oneOf([n.AlignPoint.top,n.AlignPoint.center,n.AlignPoint.bottom])}),offset:e.shape({left:e.number,top:e.number}),children:e.oneOfType([e.element,e.node]),show:e.bool,animate:e.oneOfType([e.bool,e.shape({openDuration:e.number,closeDuration:e.number})]),margin:e.shape({horizontal:e.number,vertical:e.number}),positionMode:e.oneOf(["fixed","absolute"]),scale:e.number,style:e.object,onClose:e.func,onPosition:e.func,onOpen:e.func,onKeyPress:e.func},y.defaultProps={collision:{horizontal:n.Collision.fit,vertical:n.Collision.flip},anchorAlign:{horizontal:n.AlignPoint.left,vertical:n.AlignPoint.bottom},popupAlign:{horizontal:n.AlignPoint.left,vertical:n.AlignPoint.top},offset:S,animate:!0,show:!1,margin:{horizontal:0,vertical:0},positionMode:"absolute"},y.contextType=l.ZIndexContext,y.displayName="PopupComponent";let b=y;exports.PopupWithoutContext=b; | ||
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react"),_=require("react-dom"),e=require("prop-types"),T=require("./animation.js"),l=require("@progress/kendo-react-common"),i=require("@progress/kendo-popup-common"),b=require("./util.js"),E=require("./package-metadata.js");function A(h){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>h[t]})}}return o.default=h,Object.freeze(o)}const O=A(D),N=A(_),M=100,x=1;function w(h,o){if(h===o)return!0;if(!!h!=!!o)return!1;const t=Object.getOwnPropertyNames(h),n=Object.getOwnPropertyNames(o);if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++){let s=t[r];if(h[s]!==o[s])return!1}return!0}const R={left:-1e3,top:0},y=class y extends O.Component{constructor(o){super(o),this.context=0,this.state={current:"hidden",previous:"hidden",props:{}},this._popup=null,this.show=t=>{window==null||window.addEventListener("mousedown",this.handleMouseDown),this.setPosition(t),this.animate(t.firstChild,"enter",this.onOpened),this.setState({current:"shown",previous:this.state.current})},this.setPosition=t=>{let{anchorAlign:n,popupAlign:r,collision:s,offset:c,anchor:a,margin:u,scale:d,positionMode:f}=this.props;const{width:g,height:m}=t.style;t.style.width=t.offsetWidth+"px",t.style.height=t.offsetHeight+"px";const P=i.alignElement({anchor:a,anchorAlign:n,element:t,elementAlign:r,offset:c,margin:u,positionMode:f,scale:d}),p=i.positionElement({anchor:a,anchorAlign:n,element:t,elementAlign:r,collisions:s,currentLocation:P,margin:this.props.margin});if(t.style.top=p.offset.top+"px",t.style.left=p.offset.left+"px",t.style.width=g,t.style.height=m,this._collisions={fit:p.fit,fitted:p.fitted,flip:p.flip,flipped:p.flipped},this.props.onPosition){const C={target:this,flipped:p.flipped,fitted:p.fitted};this.props.onPosition.call(void 0,C)}},this.onOpened=()=>{const t=this._popup;if(t){if(this.props.show){const{unstyled:n}=this.props,r=n&&n.uPopup;t.classList.add(...l.classNames(l.uPopup.animationContainerShown({c:r})).split(" ").filter(s=>s))}this.attachRepositionHandlers(t),this.props.onOpen&&this.props.onOpen.call(void 0,{target:this})}},this.animate=(t,n,r)=>{if(!this.props.popupAlign)return;let s;const{horizontal:c,vertical:a}=this.props.popupAlign;c==="left"&&a==="center"?s="right":c==="right"&&a==="center"?s="left":a==="top"?s="down":s="up";const u={down:"up",up:"down",left:"right",right:"left"};this._collisions&&this._collisions.flipped&&(s=u[s]);const{unstyled:d}=this.props,f=d&&d.uPopup;T.slide(t,s,this.animationDuration[n],n,r,f)},this.handleMouseDown=t=>{var s,c;const n=((s=t==null?void 0:t.target)==null?void 0:s.closest(".k-animation-container"))===null,r=((c=this.props.anchor)==null?void 0:c.contains(t==null?void 0:t.target))||!1;if(n){if(this.props.onMouseDownOutside){const a={target:this,event:t,state:this.state,isAnchorClicked:r};this.props.onMouseDownOutside.call(void 0,a)}window==null||window.removeEventListener("mousedown",this.handleMouseDown)}},this.onClosing=t=>{if(!this.props.show){const{unstyled:n}=this.props,r=n&&n.uPopup;t.classList.remove(...l.classNames(l.uPopup.animationContainerShown({c:r})).split(" ").filter(s=>s))}this.detachRepositionHandlers()},this.onClosed=()=>{this.state.current==="hiding"&&this.state.previous==="shown"&&this.setState({current:"hidden",previous:this.state.current}),this.props.onClose&&this.props.onClose.call(void 0,{target:this})},this.getCurrentZIndex=()=>this.context?this.context+x:M,l.validatePackage(E.packageMetadata),this.reposition=b.throttle(this.reposition.bind(this),b.FRAME_DURATION)}get element(){return this._popup}static getDerivedStateFromProps(o,t){const{show:n,anchor:r,anchorAlign:s,appendTo:c,collision:a,popupAlign:u,className:d,popupClass:f,style:g,offset:m,contentKey:P}=o,p={...t,props:{show:n,anchor:r,anchorAlign:s,appendTo:c,collision:a,popupAlign:u,className:d,popupClass:f,style:g,offset:m,contentKey:P}};return o.show?t.current==="hidden"||t.current==="hiding"?{...p,current:"showing",previous:t.current}:t.current==="showing"?{...p,current:"shown",previous:t.current}:t.current==="shown"&&(!w(m,t.props.offset)||!w(s,t.props.anchorAlign)||!w(c,t.props.appendTo)||!w(a,t.props.collision)||!w(u,t.props.popupAlign)||!w(g,t.props.style)||r!==t.props.anchor||f!==t.props.popupClass||d!==t.props.className)?{...p,current:"reposition",previous:t.current}:p:t.current==="hiding"||t.current==="hidden"?{...p,current:"hidden",previous:t.current}:{...p,current:"hiding",previous:t.current}}componentDidUpdate(o){this.state.current==="showing"&&this._popup?this.show(this._popup):this.state.current==="hiding"&&this._popup?(this.onClosing(this._popup),this.animate(this._popup.firstChild,"exit",this.onClosed)):this.state.current==="reposition"&&this.state.previous==="shown"?setTimeout(()=>{this.setState({current:"shown",previous:this.state.current})},0):this.state.current==="shown"&&o.contentKey!==this.props.contentKey&&this._popup&&this.setPosition(this._popup)}componentDidMount(){this.state.current==="showing"&&this._popup&&this.show(this._popup)}componentWillUnmount(){this.detachRepositionHandlers()}render(){const{children:o,className:t,popupClass:n,unstyled:r,show:s,id:c,positionMode:a}=this.props,u=r&&r.uPopup,d=this.props.appendTo?this.props.appendTo:l.canUseDOM?this.props.anchor&&this.props.anchor.ownerDocument?this.props.anchor.ownerDocument.body:document.body:void 0;this.state.current==="reposition"&&this.state.previous==="shown"&&this._popup&&this.setPosition(this._popup);const f=Object.assign({},{position:a,top:0,left:-1e4},this.props.style||{}),g=this.state.current==="hiding";if((s||g)&&d){const m=this.getCurrentZIndex(),P=O.createElement(l.ZIndexContext.Provider,{value:m},O.createElement("div",{onKeyDown:this.props.onKeyDown,className:l.classNames(l.uPopup.animationContainer({c:u}),t),id:c,ref:p=>this._popup=p,style:{zIndex:m,...f}},O.createElement("div",{className:l.classNames(l.uPopup.animationChild({c:u})),style:{transitionDelay:"0ms"}},O.createElement("div",{role:this.props.role,className:l.classNames(l.uPopup.popup({c:u}),n)},o))));return this.props.appendTo!==null?N.createPortal(P,d):P}return null}get animationDuration(){const o=this.props.animate;let t=0,n=0;return o&&(o===!0?t=n=300:(t=o.openDuration||0,n=o.closeDuration||0)),{enter:t,exit:n}}attachRepositionHandlers(o){this.detachRepositionHandlers(),this._scrollableParents=i.domUtils.scrollableParents(this.props.anchor||o),this._scrollableParents&&this._scrollableParents.map(t=>t.addEventListener("scroll",this.reposition)),window.addEventListener("resize",this.reposition)}detachRepositionHandlers(){this._scrollableParents&&(this._scrollableParents.map(o=>o.removeEventListener("scroll",this.reposition)),this._scrollableParents=void 0),window.removeEventListener("resize",this.reposition)}reposition(){this.setState({current:"reposition",previous:this.state.current})}};y.propTypes={anchor:function(o){const t=o.anchor;return t&&typeof t.nodeType!="number"?new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. Validation failed."):null},appendTo:function(o){const t=o.appendTo;return t&&typeof t.nodeType!="number"?new Error("Invalid prop `appendTo` supplied to `Kendo React Popup`. Validation failed."):null},className:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),id:e.string,popupClass:e.oneOfType([e.string,e.arrayOf(e.string),e.object]),collision:e.shape({horizontal:e.oneOf([i.Collision.fit,i.Collision.flip,i.Collision.none]),vertical:e.oneOf([i.Collision.fit,i.Collision.flip,i.Collision.none])}),anchorAlign:e.shape({horizontal:e.oneOf([i.AlignPoint.left,i.AlignPoint.center,i.AlignPoint.right]),vertical:e.oneOf([i.AlignPoint.top,i.AlignPoint.center,i.AlignPoint.bottom])}),popupAlign:e.shape({horizontal:e.oneOf([i.AlignPoint.left,i.AlignPoint.center,i.AlignPoint.right]),vertical:e.oneOf([i.AlignPoint.top,i.AlignPoint.center,i.AlignPoint.bottom])}),offset:e.shape({left:e.number,top:e.number}),children:e.oneOfType([e.element,e.node]),show:e.bool,animate:e.oneOfType([e.bool,e.shape({openDuration:e.number,closeDuration:e.number})]),margin:e.shape({horizontal:e.number,vertical:e.number}),positionMode:e.oneOf(["fixed","absolute"]),scale:e.number,style:e.object,onClose:e.func,onPosition:e.func,onOpen:e.func,onKeyPress:e.func,onMouseDownOutside:e.func},y.defaultProps={collision:{horizontal:i.Collision.fit,vertical:i.Collision.flip},anchorAlign:{horizontal:i.AlignPoint.left,vertical:i.AlignPoint.bottom},popupAlign:{horizontal:i.AlignPoint.left,vertical:i.AlignPoint.top},offset:R,animate:!0,show:!1,margin:{horizontal:0,vertical:0},positionMode:"absolute"},y.contextType=l.ZIndexContext,y.displayName="PopupComponent";let v=y;exports.PopupWithoutContext=v; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95991
1105