@progress/kendo-react-dialogs 11.4.0-develop.2 → 11.4.0-develop.3
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.
- package/Window.js +1 -1
- package/Window.mjs +19 -19
- package/dist/cdn/js/kendo-react-dialogs.js +1 -1
- package/package.json +4 -4
package/Window.js
CHANGED
|
@@ -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 strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),R=require("react-dom"),h=require("prop-types"),x=require("./WindowTitlebar.js"),o=require("@progress/kendo-react-common"),U=require("./WindowResizeHandlers.js"),N=require("./MiddleLayerOptimization.js"),s=require("./StageEnum.js"),W=require("./WindowActionsBar.js"),f=require("./constants.js"),M=require("./utils.js");function v(w){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(w){for(const t in w)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(w,t);Object.defineProperty(i,t,e.get?e:{enumerable:!0,get:()=>w[t]})}}return i.default=w,Object.freeze(i)}const r=v(F),z=v(R),S=300,m=300,E=120,D=100,p=5,g=class g extends r.Component{constructor(i){super(i),this.context=0,this.draggable=null,this.offSetCoordinates={x:0,y:0},this.titleId=this.generateTitleId(),this.mounted=!1,this.activeElement=null,this.onKeyDown=t=>{if(this.props.modal&&o.keepFocusInContainer(t,this.element),t.target!==t.currentTarget)return;const e=this.props.minWidth||E,n=this.props.minHeight||D;if((t.metaKey||t.ctrlKey)&&this.props.resizable){switch(t.keyCode){case o.Keys.up:t.preventDefault(),n<=this.height-p&&this.setState({height:this.height-p});break;case o.Keys.down:t.preventDefault(),this.setState({height:this.height+p});break;case o.Keys.left:e<=this.width-p&&this.setState({width:this.width-p});break;case o.Keys.right:this.setState({width:this.width+p});break;default:return}this.dispatchMoveEvent(this.props.onResize,t,!1,void 0);return}if(t.altKey){switch(t.keyCode){case o.Keys.up:this.windowStage===s.windowStage.MINIMIZED?(this.handleRestore(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.DEFAULT})):this.windowStage===s.windowStage.DEFAULT&&(this.handleFullscreen(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.FULLSCREEN}));break;case o.Keys.down:this.windowStage===s.windowStage.FULLSCREEN?(this.handleRestore(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.DEFAULT})):this.windowStage===s.windowStage.DEFAULT&&(this.handleMinimize(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.MINIMIZED}));break}return}if(!t.ctrlKey)switch(t.keyCode){case o.Keys.esc:this.props.onClose&&this.handleCloseWindow(t);return;case o.Keys.up:this.setState(a=>({top:a.top-p}));break;case o.Keys.down:this.setState(a=>({top:a.top+p}));break;case o.Keys.left:this.setState(a=>({left:a.left-p}));break;case o.Keys.right:this.setState(a=>({left:a.left+p}));break;default:return}this.dispatchMoveEvent(this.props.onMove,t,!1,void 0)},this.onPress=t=>{const e=t.event;this.windowCoordinatesState.differenceLeft=e.pageX-this.left,this.windowCoordinatesState.differenceTop=e.pageY-this.top},this.onDrag=t=>{const e=t.event;e.originalEvent.preventDefault(),this.windowStage!==s.windowStage.FULLSCREEN&&this.props.draggable&&(this.setState({top:Math.max(e.pageY-this.windowCoordinatesState.differenceTop,0),left:e.pageX-this.windowCoordinatesState.differenceLeft,isDragging:!0}),this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!1))},this.onRelease=t=>{const e=t.event;this.windowStage!==s.windowStage.FULLSCREEN&&this.props.draggable&&this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!0),this.setState({isDragging:!1})},this.onFocus=()=>{this._blurTimeout?(clearTimeout(this._blurTimeout),this._blurTimeout=void 0):this.setState({focused:!0,zIndex:M.getMaxZIndex(this.getCurrentZIndex(),this.getDocument(),this._id)})},this.onBlur=()=>{clearTimeout(this._blurTimeout);const t=this.getWindow();t&&(this._blurTimeout=t.setTimeout(()=>{this.mounted&&this.setState({focused:!1}),this._blurTimeout=void 0}))},this.getInitialTop=()=>{if(this.props.top!==void 0)return this.props.top;if(this.props.initialTop!==void 0)return this.props.initialTop;let t=m;if(this.props.height!==void 0?t=this.props.height:this.props.initialHeight!==void 0&&(t=this.props.initialHeight),this.props.appendTo)return this.props.appendTo.offsetHeight/2-t/2;const e=this.getWindow();return e?e.innerHeight/2-t/2:0},this.getInitialLeft=()=>{if(this.props.left!==void 0)return this.props.left;if(this.props.initialLeft!==void 0)return this.props.initialLeft;let t=S;if(this.props.width!==void 0?t=this.props.width:this.props.initialWidth!==void 0&&(t=this.props.initialWidth),this.props.appendTo)return this.props.appendTo.offsetWidth/2-t/2;const e=this.getWindow();return e?e.innerWidth/2-t/2:0},this.getInitialWidth=()=>{let t=S;return this.props.width!==void 0?t=this.props.width:this.props.initialWidth!==void 0&&(t=this.props.initialWidth),t},this.getInitialHeight=()=>{let t=m;return this.props.height!==void 0?t=this.props.height:this.props.initialHeight!==void 0&&(t=this.props.initialHeight),t},this.handleMinimize=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height,this.setState({stage:s.windowStage.MINIMIZED,height:0}),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.MINIMIZED})},this.handleFullscreen=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height;const e=this.getWindow(),n=e?e.innerWidth:0,d=e?e.innerHeight:0;this.setState({left:0,top:0,width:this.props.appendTo?this.props.appendTo.offsetWidth:n,height:this.props.appendTo?this.props.appendTo.offsetHeight:d,stage:s.windowStage.FULLSCREEN}),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.FULLSCREEN})},this.handleRestore=t=>{t.preventDefault(),this.windowStage===s.windowStage.FULLSCREEN?this.setState({stage:s.windowStage.DEFAULT,left:this.windowCoordinatesState.leftBeforeAction,top:this.windowCoordinatesState.topBeforeAction,width:this.windowCoordinatesState.widthBeforeAction,height:this.windowCoordinatesState.heightBeforeAction}):this.windowStage===s.windowStage.MINIMIZED&&this.setState({stage:s.windowStage.DEFAULT,height:this.windowCoordinatesState.heightBeforeAction}),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.DEFAULT})},this.handleCloseWindow=t=>{t.preventDefault(),o.dispatchEvent(this.props.onClose,t,this,{state:void 0})},this.handleDoubleClick=t=>{this.windowStage===s.windowStage.FULLSCREEN||this.windowStage===s.windowStage.MINIMIZED?this.handleRestore(t):this.handleFullscreen(t)},this.handleResize=(t,e)=>{const n=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,d=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,a=this.width,l=this.height,C=this.props.minWidth||E,I=this.props.minHeight||D,T=this.top-d,b=this.left-n,L=n-this.left,y=d-this.top,c=Object.assign({},this.state,{isDragging:!e.end});e.direction.indexOf("n")>=0&&I-(l+T)<0&&(this.top>0&&(c.height=l+T),c.top=d),e.direction.indexOf("s")>=0&&I-y<0&&(c.height=y),e.direction.indexOf("w")>=0&&C-(a+b)<0&&(this.left>0&&(c.width=a+b),c.left=n),e.direction.indexOf("e")>=0&&C-L<0&&(c.width=L),this.setState(c),this.dispatchMoveEvent(this.props.onResize,t,!0,e.end)},this.dispatchMoveEvent=(t,e,n,d)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:n,end:d,target:this,left:this.state.left,top:this.state.top,width:this.state.width,hight:this.state.height,height:this.state.height})},this.handleBrowserWindowResize=()=>{if(this.windowStage===s.windowStage.FULLSCREEN){const t=this.getWindow(),e=t?t.innerWidth:0,n=t?t.innerHeight:0;this.setState({width:this.props.appendTo?this.props.appendTo.offsetWidth:e,height:this.props.appendTo?this.props.appendTo.offsetHeight:n})}},this.getCurrentZIndex=()=>!this.state||this.context===void 0?this.context?this.context:f.DEFAULT_DIALOGS_ZINDEX:this.state.zIndex>(this.context?this.context+f.ZINDEX_DIALOGS_STEP:0)?this.state.zIndex:this.context+f.ZINDEX_DIALOGS_STEP,this.getDocument=()=>{const t=o.canUseDOM?document:null;return this.props.appendTo?this.props.appendTo.ownerDocument:t},this.getWindow=()=>{const t=this.getDocument();return t&&t.defaultView},this.state={stage:this.props.stage||s.windowStage.DEFAULT,isDragging:!1,top:0,left:0,width:S,height:m,focused:!0,zIndex:f.DEFAULT_DIALOGS_ZINDEX},o.canUseDOM&&(this.activeElement=document.activeElement)}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){this.element&&this.props.autoFocus&&this.element.focus({preventScroll:!0});const i=this.getWindow();i&&i.addEventListener("resize",this.handleBrowserWindowResize),this.setState({stage:this.props.stage||s.windowStage.DEFAULT,isDragging:!1,top:this.getInitialTop(),left:this.getInitialLeft(),width:this.getInitialWidth(),height:this.getInitialHeight(),focused:!0,zIndex:M.getMaxZIndex(this.getCurrentZIndex(),this.getDocument(),this._id)}),this.windowCoordinatesState={leftBeforeAction:this.getInitialLeft(),topBeforeAction:this.getInitialTop(),widthBeforeAction:this.getInitialWidth(),heightBeforeAction:this.getInitialHeight()};const t=this.getDocument();if(this.props.appendTo&&t){const e=this.props.appendTo.getBoundingClientRect(),n=t.body.getBoundingClientRect();this.offSetCoordinates.x=e.left-n.left,this.offSetCoordinates.y=e.top-n.top}this.mounted=!0}componentWillUnmount(){const i=this.getWindow();i&&i.removeEventListener("resize",this.handleBrowserWindowResize),this.mounted=!1,setTimeout(()=>{var t;!this.element&&this.activeElement&&o.canUseDOM&&(document.contains(this.activeElement)?this.activeElement.focus({preventScroll:!0}):this.activeElement.id&&((t=document.getElementById(this.activeElement.id))==null||t.focus({preventScroll:!0})))})}componentDidUpdate(i){this.props.left&&i.left!==this.props.left&&this.setState({left:this.props.left}),this.props.top&&i.top!==this.props.top&&this.setState({top:this.props.top});const t=this.getDocument();if(this.props.appendTo&&t){const e=this.props.appendTo.getBoundingClientRect(),n=t.body.getBoundingClientRect();this.offSetCoordinates.x=e.left-n.left,this.offSetCoordinates.y=e.top-n.top}this.mounted=!0}render(){const i=r.Children.toArray(this.props.children),t=this.getContent(i),e=this.getActionBar(i),n=this.getCurrentZIndex(),d=o.classNames("k-window",this.props.className,{[`k-window-${this.props.themeColor}`]:this.props.themeColor,"k-window-minimized":this.state.stage==="MINIMIZED","k-focus":this.state.focused}),a=r.createElement(o.ZIndexContext.Provider,{value:n},r.createElement(r.Fragment,null,this.props.modal&&r.createElement("div",{className:"k-overlay",style:{zIndex:n,...this.props.overlayStyle}}),r.createElement("div",{id:this.props.id,[f.DATA_DIALOGS_ID]:this._id,tabIndex:0,role:"dialog","aria-labelledby":this.titleId,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,ref:l=>{this.windowElement=l,this.element=l},className:d,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:n,...this.props.style}},r.createElement(N.MiddleLayerOptimization,{shouldUpdateOnDrag:this.props.shouldUpdateOnDrag||!1,isDragging:this.state.isDragging},r.createElement(o.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,autoScroll:!1,ref:l=>{this.draggable=l}},r.createElement(x.WindowTitleBar,{stage:this.windowStage,onDoubleClick:this.props.doubleClickStageChange?this.handleDoubleClick:void 0,onMinimizeButtonClick:this.handleMinimize,onFullScreenButtonClick:this.handleFullscreen,onRestoreButtonClick:this.handleRestore,onCloseButtonClick:this.handleCloseWindow,closeButton:this.props.closeButton,minimizeButton:this.props.minimizeButton,maximizeButton:this.props.maximizeButton,restoreButton:this.props.restoreButton,id:this.titleId},this.props.title)),this.windowStage!==s.windowStage.MINIMIZED?r.createElement(r.Fragment,null,r.createElement("div",{className:"k-window-content"},t),e):null,this.windowStage===s.windowStage.DEFAULT&&this.props.resizable?r.createElement(U.ResizeHandlers,{onResize:this.handleResize}):null))));return o.canUseDOM?this.props.appendTo!==null?z.createPortal(a,this.props.appendTo||document.body):a:null}get top(){return this.windowStage!==s.windowStage.FULLSCREEN?Math.max(this.props.top||this.state.top,0):0}get left(){return this.windowStage!==s.windowStage.FULLSCREEN?Math.max(this.props.left||this.state.left,0):0}get width(){let i=this.props.width||this.state.width;if(this.windowStage===s.windowStage.FULLSCREEN){if(this.props.appendTo)return i=this.props.appendTo.offsetWidth,i;const t=this.getWindow();i=t?t.innerWidth:0}return i}get height(){let i=this.props.height||this.state.height;if(this.windowStage===s.windowStage.FULLSCREEN){if(this.props.appendTo)return i=this.props.appendTo.offsetHeight,i;const t=this.getWindow();i=t?t.innerHeight:0}else this.windowStage===s.windowStage.MINIMIZED&&(i=0);return i}get windowStage(){return this.props.stage||this.state.stage}getActionBar(i){return i.filter(t=>t&&t.type===W.WindowActionsBar)}getContent(i){return i.filter(t=>t&&t.type!==W.WindowActionsBar)}generateTitleId(){return"window-title-"+this._id}};g.displayName="Window",g.propTypes={width:h.number,height:h.number,left:h.number,top:h.number,initialWidth:h.number,initialHeight:h.number,initialLeft:h.number,initialTop:h.number,minWidth:h.number,minHeight:h.number,resizable:h.bool,draggable:h.bool,title:h.any,shouldUpdateOnDrag:h.bool,stage:h.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),className:h.string,id:h.string,style:h.object,overlayStyle:h.object,autoFocus:h.bool},g.defaultProps={minWidth:E,minHeight:D,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},g.contextType=o.ZIndexContext;let u=g;const A=o.createPropsContext(),B=o.withIdHOC(o.withPropsContext(A,u));B.displayName="KendoReactWindow";exports.Window=B;exports.WindowPropsContext=A;exports.WindowWithoutContext=u;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),R=require("react-dom"),h=require("prop-types"),x=require("./WindowTitlebar.js"),o=require("@progress/kendo-react-common"),U=require("./WindowResizeHandlers.js"),N=require("./MiddleLayerOptimization.js"),s=require("./StageEnum.js"),W=require("./WindowActionsBar.js"),f=require("./constants.js"),M=require("./utils.js");function v(w){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(w){for(const t in w)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(w,t);Object.defineProperty(i,t,e.get?e:{enumerable:!0,get:()=>w[t]})}}return i.default=w,Object.freeze(i)}const r=v(F),z=v(R),S=300,m=300,E=120,D=100,p=5,g=class g extends r.Component{constructor(i){super(i),this.context=0,this.draggable=null,this.offSetCoordinates={x:0,y:0},this.titleId=this.generateTitleId(),this.mounted=!1,this.activeElement=null,this.onKeyDown=t=>{if(this.props.modal&&o.keepFocusInContainer(t,this.element),t.target!==t.currentTarget)return;const e=this.props.minWidth||E,n=this.props.minHeight||D;if((t.metaKey||t.ctrlKey)&&this.props.resizable){switch(t.keyCode){case o.Keys.up:t.preventDefault(),n<=this.height-p&&this.setState({height:this.height-p});break;case o.Keys.down:t.preventDefault(),this.setState({height:this.height+p});break;case o.Keys.left:e<=this.width-p&&this.setState({width:this.width-p});break;case o.Keys.right:this.setState({width:this.width+p});break;default:return}this.dispatchMoveEvent(this.props.onResize,t,!1,void 0);return}if(t.altKey){switch(t.keyCode){case o.Keys.up:this.windowStage===s.windowStage.MINIMIZED?(this.handleRestore(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.DEFAULT})):this.windowStage===s.windowStage.DEFAULT&&(this.handleFullscreen(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.FULLSCREEN}));break;case o.Keys.down:this.windowStage===s.windowStage.FULLSCREEN?(this.handleRestore(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.DEFAULT})):this.windowStage===s.windowStage.DEFAULT&&(this.handleMinimize(t),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.MINIMIZED}));break}return}if(!t.ctrlKey)switch(t.keyCode){case o.Keys.esc:this.props.onClose&&this.handleCloseWindow(t);return;case o.Keys.up:this.setState(a=>({top:a.top-p}));break;case o.Keys.down:this.setState(a=>({top:a.top+p}));break;case o.Keys.left:this.setState(a=>({left:a.left-p}));break;case o.Keys.right:this.setState(a=>({left:a.left+p}));break;default:return}this.dispatchMoveEvent(this.props.onMove,t,!1,void 0)},this.onPress=t=>{const e=t.event;this.windowCoordinatesState.differenceLeft=e.pageX-this.left,this.windowCoordinatesState.differenceTop=e.pageY-this.top},this.onDrag=t=>{const e=t.event;e.originalEvent.preventDefault(),this.windowStage!==s.windowStage.FULLSCREEN&&this.props.draggable&&(this.setState({top:Math.max(e.pageY-this.windowCoordinatesState.differenceTop,0),left:e.pageX-this.windowCoordinatesState.differenceLeft,isDragging:!0}),this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!1))},this.onRelease=t=>{const e=t.event;this.windowStage!==s.windowStage.FULLSCREEN&&this.props.draggable&&this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!0),this.setState({isDragging:!1})},this.onFocus=()=>{this._blurTimeout?(clearTimeout(this._blurTimeout),this._blurTimeout=void 0):this.setState({focused:!0,zIndex:M.getMaxZIndex(this.getCurrentZIndex(),this.getDocument(),this._id)})},this.onBlur=()=>{clearTimeout(this._blurTimeout);const t=this.getWindow();t&&(this._blurTimeout=t.setTimeout(()=>{this.mounted&&this.setState({focused:!1}),this._blurTimeout=void 0}))},this.getInitialTop=()=>{if(this.props.top!==void 0)return this.props.top;if(this.props.initialTop!==void 0)return this.props.initialTop;let t=m;if(this.props.height!==void 0?t=this.props.height:this.props.initialHeight!==void 0&&(t=this.props.initialHeight),this.props.appendTo)return this.props.appendTo.offsetHeight/2-t/2;const e=this.getWindow();return e?e.innerHeight/2-t/2:0},this.getInitialLeft=()=>{if(this.props.left!==void 0)return this.props.left;if(this.props.initialLeft!==void 0)return this.props.initialLeft;let t=S;if(this.props.width!==void 0?t=this.props.width:this.props.initialWidth!==void 0&&(t=this.props.initialWidth),this.props.appendTo)return this.props.appendTo.offsetWidth/2-t/2;const e=this.getWindow();return e?e.innerWidth/2-t/2:0},this.getInitialWidth=()=>{let t=S;return this.props.width!==void 0?t=this.props.width:this.props.initialWidth!==void 0&&(t=this.props.initialWidth),t},this.getInitialHeight=()=>{let t=m;return this.props.height!==void 0?t=this.props.height:this.props.initialHeight!==void 0&&(t=this.props.initialHeight),t},this.handleMinimize=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height,this.setState({stage:s.windowStage.MINIMIZED,height:0}),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.MINIMIZED})},this.handleFullscreen=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height;const e=this.getWindow(),n=e?e.innerWidth:0,d=e?e.innerHeight:0;this.setState({left:0,top:0,width:this.props.appendTo?this.props.appendTo.offsetWidth:n,height:this.props.appendTo?this.props.appendTo.offsetHeight:d,stage:s.windowStage.FULLSCREEN}),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.FULLSCREEN})},this.handleRestore=t=>{t.preventDefault(),this.windowStage===s.windowStage.FULLSCREEN?this.setState({stage:s.windowStage.DEFAULT,left:this.windowCoordinatesState.leftBeforeAction,top:this.windowCoordinatesState.topBeforeAction,width:this.windowCoordinatesState.widthBeforeAction,height:this.windowCoordinatesState.heightBeforeAction}):this.windowStage===s.windowStage.MINIMIZED&&this.setState({stage:s.windowStage.DEFAULT,height:this.windowCoordinatesState.heightBeforeAction}),o.dispatchEvent(this.props.onStageChange,t,this,{state:s.windowStage.DEFAULT})},this.handleCloseWindow=t=>{t.preventDefault(),o.dispatchEvent(this.props.onClose,t,this,{state:void 0})},this.handleDoubleClick=t=>{this.windowStage===s.windowStage.FULLSCREEN||this.windowStage===s.windowStage.MINIMIZED?this.handleRestore(t):this.handleFullscreen(t)},this.handleResize=(t,e)=>{const n=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,d=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,a=this.width,l=this.height,C=this.props.minWidth||E,T=this.props.minHeight||D,I=this.top-d,L=this.left-n,b=n-this.left,y=d-this.top,c=Object.assign({},this.state,{isDragging:!e.end});e.direction.indexOf("n")>=0&&T-(l+I)<0&&(this.top>0&&(c.height=l+I),c.top=d),e.direction.indexOf("s")>=0&&T-y<0&&(c.height=y),e.direction.indexOf("w")>=0&&C-(a+L)<0&&(this.left>0&&(c.width=a+L),c.left=n),e.direction.indexOf("e")>=0&&C-b<0&&(c.width=b),this.setState(c),this.dispatchMoveEvent(this.props.onResize,t,!0,e.end)},this.dispatchMoveEvent=(t,e,n,d)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:n,end:d,target:this,left:this.state.left,top:this.state.top,width:this.state.width,hight:this.state.height,height:this.state.height})},this.handleBrowserWindowResize=()=>{if(this.windowStage===s.windowStage.FULLSCREEN){const t=this.getWindow(),e=t?t.innerWidth:0,n=t?t.innerHeight:0;this.setState({width:this.props.appendTo?this.props.appendTo.offsetWidth:e,height:this.props.appendTo?this.props.appendTo.offsetHeight:n})}},this.getCurrentZIndex=()=>!this.state||this.context===void 0?this.context?this.context:f.DEFAULT_DIALOGS_ZINDEX:this.state.zIndex>(this.context?this.context+f.ZINDEX_DIALOGS_STEP:0)?this.state.zIndex:this.context+f.ZINDEX_DIALOGS_STEP,this.getDocument=()=>{const t=o.canUseDOM?document:null;return this.props.appendTo?this.props.appendTo.ownerDocument:t},this.getWindow=()=>{const t=this.getDocument();return t&&t.defaultView},this.state={stage:this.props.stage||s.windowStage.DEFAULT,isDragging:!1,top:0,left:0,width:S,height:m,focused:!0,zIndex:f.DEFAULT_DIALOGS_ZINDEX},o.canUseDOM&&(this.activeElement=document.activeElement)}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){this.element&&this.props.autoFocus&&this.element.focus({preventScroll:!0});const i=this.getWindow();i&&i.addEventListener("resize",this.handleBrowserWindowResize),this.setState({stage:this.props.stage||s.windowStage.DEFAULT,isDragging:!1,top:this.getInitialTop(),left:this.getInitialLeft(),width:this.getInitialWidth(),height:this.getInitialHeight(),focused:!0,zIndex:M.getMaxZIndex(this.getCurrentZIndex(),this.getDocument(),this._id)}),this.windowCoordinatesState={leftBeforeAction:this.getInitialLeft(),topBeforeAction:this.getInitialTop(),widthBeforeAction:this.getInitialWidth(),heightBeforeAction:this.getInitialHeight()};const t=this.getDocument();if(this.props.appendTo&&t){const e=this.props.appendTo.getBoundingClientRect(),n=t.body.getBoundingClientRect();this.offSetCoordinates.x=e.left-n.left,this.offSetCoordinates.y=e.top-n.top}this.mounted=!0}componentWillUnmount(){const i=this.getWindow();i&&i.removeEventListener("resize",this.handleBrowserWindowResize),this.mounted=!1,setTimeout(()=>{var t;!this.element&&this.activeElement&&o.canUseDOM&&(document.contains(this.activeElement)?this.activeElement.focus({preventScroll:!0}):this.activeElement.id&&((t=document.getElementById(this.activeElement.id))==null||t.focus({preventScroll:!0})))})}componentDidUpdate(i){this.props.left&&i.left!==this.props.left&&this.setState({left:this.props.left}),this.props.top&&i.top!==this.props.top&&this.setState({top:this.props.top}),this.props.initialLeft&&i.initialLeft!==this.props.initialLeft&&this.setState({left:this.props.initialLeft}),this.props.initialTop&&i.initialTop!==this.props.initialTop&&this.setState({top:this.props.initialTop});const t=this.getDocument();if(this.props.appendTo&&t){const e=this.props.appendTo.getBoundingClientRect(),n=t.body.getBoundingClientRect();this.offSetCoordinates.x=e.left-n.left,this.offSetCoordinates.y=e.top-n.top}this.mounted=!0}render(){const i=r.Children.toArray(this.props.children),t=this.getContent(i),e=this.getActionBar(i),n=this.getCurrentZIndex(),d=o.classNames("k-window",this.props.className,{[`k-window-${this.props.themeColor}`]:this.props.themeColor,"k-window-minimized":this.state.stage==="MINIMIZED","k-focus":this.state.focused}),a=r.createElement(o.ZIndexContext.Provider,{value:n},r.createElement(r.Fragment,null,this.props.modal&&r.createElement("div",{className:"k-overlay",style:{zIndex:n,...this.props.overlayStyle}}),r.createElement("div",{id:this.props.id,[f.DATA_DIALOGS_ID]:this._id,tabIndex:0,role:"dialog","aria-labelledby":this.titleId,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,ref:l=>{this.windowElement=l,this.element=l},className:d,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:n,...this.props.style}},r.createElement(N.MiddleLayerOptimization,{shouldUpdateOnDrag:this.props.shouldUpdateOnDrag||!1,isDragging:this.state.isDragging},r.createElement(o.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,autoScroll:!1,ref:l=>{this.draggable=l}},r.createElement(x.WindowTitleBar,{stage:this.windowStage,onDoubleClick:this.props.doubleClickStageChange?this.handleDoubleClick:void 0,onMinimizeButtonClick:this.handleMinimize,onFullScreenButtonClick:this.handleFullscreen,onRestoreButtonClick:this.handleRestore,onCloseButtonClick:this.handleCloseWindow,closeButton:this.props.closeButton,minimizeButton:this.props.minimizeButton,maximizeButton:this.props.maximizeButton,restoreButton:this.props.restoreButton,id:this.titleId},this.props.title)),this.windowStage!==s.windowStage.MINIMIZED?r.createElement(r.Fragment,null,r.createElement("div",{className:"k-window-content"},t),e):null,this.windowStage===s.windowStage.DEFAULT&&this.props.resizable?r.createElement(U.ResizeHandlers,{onResize:this.handleResize}):null))));return o.canUseDOM?this.props.appendTo!==null?z.createPortal(a,this.props.appendTo||document.body):a:null}get top(){return this.windowStage!==s.windowStage.FULLSCREEN?Math.max(this.props.top||this.state.top,0):0}get left(){return this.windowStage!==s.windowStage.FULLSCREEN?Math.max(this.props.left||this.state.left,0):0}get width(){let i=this.props.width||this.state.width;if(this.windowStage===s.windowStage.FULLSCREEN){if(this.props.appendTo)return i=this.props.appendTo.offsetWidth,i;const t=this.getWindow();i=t?t.innerWidth:0}return i}get height(){let i=this.props.height||this.state.height;if(this.windowStage===s.windowStage.FULLSCREEN){if(this.props.appendTo)return i=this.props.appendTo.offsetHeight,i;const t=this.getWindow();i=t?t.innerHeight:0}else this.windowStage===s.windowStage.MINIMIZED&&(i=0);return i}get windowStage(){return this.props.stage||this.state.stage}getActionBar(i){return i.filter(t=>t&&t.type===W.WindowActionsBar)}getContent(i){return i.filter(t=>t&&t.type!==W.WindowActionsBar)}generateTitleId(){return"window-title-"+this._id}};g.displayName="Window",g.propTypes={width:h.number,height:h.number,left:h.number,top:h.number,initialWidth:h.number,initialHeight:h.number,initialLeft:h.number,initialTop:h.number,minWidth:h.number,minHeight:h.number,resizable:h.bool,draggable:h.bool,title:h.any,shouldUpdateOnDrag:h.bool,stage:h.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),className:h.string,id:h.string,style:h.object,overlayStyle:h.object,autoFocus:h.bool},g.defaultProps={minWidth:E,minHeight:D,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},g.contextType=o.ZIndexContext;let u=g;const A=o.createPropsContext(),B=o.withIdHOC(o.withPropsContext(A,u));B.displayName="KendoReactWindow";exports.Window=B;exports.WindowPropsContext=A;exports.WindowWithoutContext=u;
|
package/Window.mjs
CHANGED
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as h from "react";
|
|
9
|
-
import * as
|
|
9
|
+
import * as v from "react-dom";
|
|
10
10
|
import n from "prop-types";
|
|
11
11
|
import { WindowTitleBar as R } from "./WindowTitlebar.mjs";
|
|
12
12
|
import { keepFocusInContainer as x, Keys as a, dispatchEvent as l, canUseDOM as u, ZIndexContext as M, classNames as N, Draggable as U, createPropsContext as H, withIdHOC as z, withPropsContext as k } from "@progress/kendo-react-common";
|
|
13
13
|
import { ResizeHandlers as _ } from "./WindowResizeHandlers.mjs";
|
|
14
14
|
import { MiddleLayerOptimization as Z } from "./MiddleLayerOptimization.mjs";
|
|
15
15
|
import { windowStage as i } from "./StageEnum.mjs";
|
|
16
|
-
import { WindowActionsBar as
|
|
17
|
-
import { DEFAULT_DIALOGS_ZINDEX as
|
|
18
|
-
import { getMaxZIndex as
|
|
16
|
+
import { WindowActionsBar as F } from "./WindowActionsBar.mjs";
|
|
17
|
+
import { DEFAULT_DIALOGS_ZINDEX as y, ZINDEX_DIALOGS_STEP as A, DATA_DIALOGS_ID as O } from "./constants.mjs";
|
|
18
|
+
import { getMaxZIndex as B } from "./utils.mjs";
|
|
19
19
|
const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component {
|
|
20
20
|
constructor(s) {
|
|
21
21
|
super(s), this.context = 0, this.draggable = null, this.offSetCoordinates = { x: 0, y: 0 }, this.titleId = this.generateTitleId(), this.mounted = !1, this.activeElement = null, this.onKeyDown = (t) => {
|
|
@@ -92,7 +92,7 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
92
92
|
}, this.onFocus = () => {
|
|
93
93
|
this._blurTimeout ? (clearTimeout(this._blurTimeout), this._blurTimeout = void 0) : this.setState({
|
|
94
94
|
focused: !0,
|
|
95
|
-
zIndex:
|
|
95
|
+
zIndex: B(this.getCurrentZIndex(), this.getDocument(), this._id)
|
|
96
96
|
});
|
|
97
97
|
}, this.onBlur = () => {
|
|
98
98
|
clearTimeout(this._blurTimeout);
|
|
@@ -157,8 +157,8 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
157
157
|
}, this.handleDoubleClick = (t) => {
|
|
158
158
|
this.windowStage === i.FULLSCREEN || this.windowStage === i.MINIMIZED ? this.handleRestore(t) : this.handleFullscreen(t);
|
|
159
159
|
}, this.handleResize = (t, e) => {
|
|
160
|
-
const o = this.props.appendTo ? t.pageX - this.offSetCoordinates.x : t.pageX, p = this.props.appendTo ? t.pageY - this.offSetCoordinates.y : t.pageY, r = this.width, c = this.height, D = this.props.minWidth || S,
|
|
161
|
-
e.direction.indexOf("n") >= 0 &&
|
|
160
|
+
const o = this.props.appendTo ? t.pageX - this.offSetCoordinates.x : t.pageX, p = this.props.appendTo ? t.pageY - this.offSetCoordinates.y : t.pageY, r = this.width, c = this.height, D = this.props.minWidth || S, T = this.props.minHeight || E, I = this.top - p, L = this.left - o, b = o - this.left, W = p - this.top, g = Object.assign({}, this.state, { isDragging: !e.end });
|
|
161
|
+
e.direction.indexOf("n") >= 0 && T - (c + I) < 0 && (this.top > 0 && (g.height = c + I), g.top = p), e.direction.indexOf("s") >= 0 && T - W < 0 && (g.height = W), e.direction.indexOf("w") >= 0 && D - (r + L) < 0 && (this.left > 0 && (g.width = r + L), g.left = o), e.direction.indexOf("e") >= 0 && D - b < 0 && (g.width = b), this.setState(g), this.dispatchMoveEvent(this.props.onResize, t, !0, e.end);
|
|
162
162
|
}, this.dispatchMoveEvent = (t, e, o, p) => {
|
|
163
163
|
t && t.call(void 0, {
|
|
164
164
|
nativeEvent: e.nativeEvent ? e.nativeEvent : e.originalEvent,
|
|
@@ -179,7 +179,7 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
179
179
|
height: this.props.appendTo ? this.props.appendTo.offsetHeight : o
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
}, this.getCurrentZIndex = () => !this.state || this.context === void 0 ? this.context ? this.context :
|
|
182
|
+
}, this.getCurrentZIndex = () => !this.state || this.context === void 0 ? this.context ? this.context : y : this.state.zIndex > (this.context ? this.context + A : 0) ? this.state.zIndex : this.context + A, this.getDocument = () => {
|
|
183
183
|
const t = u ? document : null;
|
|
184
184
|
return this.props.appendTo ? this.props.appendTo.ownerDocument : t;
|
|
185
185
|
}, this.getWindow = () => {
|
|
@@ -193,7 +193,7 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
193
193
|
width: w,
|
|
194
194
|
height: m,
|
|
195
195
|
focused: !0,
|
|
196
|
-
zIndex:
|
|
196
|
+
zIndex: y
|
|
197
197
|
}, u && (this.activeElement = document.activeElement);
|
|
198
198
|
}
|
|
199
199
|
get _id() {
|
|
@@ -213,7 +213,7 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
213
213
|
width: this.getInitialWidth(),
|
|
214
214
|
height: this.getInitialHeight(),
|
|
215
215
|
focused: !0,
|
|
216
|
-
zIndex:
|
|
216
|
+
zIndex: B(this.getCurrentZIndex(), this.getDocument(), this._id)
|
|
217
217
|
}), this.windowCoordinatesState = {
|
|
218
218
|
leftBeforeAction: this.getInitialLeft(),
|
|
219
219
|
topBeforeAction: this.getInitialTop(),
|
|
@@ -241,7 +241,7 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
241
241
|
* @hidden
|
|
242
242
|
*/
|
|
243
243
|
componentDidUpdate(s) {
|
|
244
|
-
this.props.left && s.left !== this.props.left && this.setState({ left: this.props.left }), this.props.top && s.top !== this.props.top && this.setState({ top: this.props.top });
|
|
244
|
+
this.props.left && s.left !== this.props.left && this.setState({ left: this.props.left }), this.props.top && s.top !== this.props.top && this.setState({ top: this.props.top }), this.props.initialLeft && s.initialLeft !== this.props.initialLeft && this.setState({ left: this.props.initialLeft }), this.props.initialTop && s.initialTop !== this.props.initialTop && this.setState({ top: this.props.initialTop });
|
|
245
245
|
const t = this.getDocument();
|
|
246
246
|
if (this.props.appendTo && t) {
|
|
247
247
|
const e = this.props.appendTo.getBoundingClientRect(), o = t.body.getBoundingClientRect();
|
|
@@ -329,7 +329,7 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
329
329
|
this.windowStage === i.DEFAULT && this.props.resizable ? /* @__PURE__ */ h.createElement(_, { onResize: this.handleResize }) : null
|
|
330
330
|
)
|
|
331
331
|
)));
|
|
332
|
-
return u ? this.props.appendTo !== null ?
|
|
332
|
+
return u ? this.props.appendTo !== null ? v.createPortal(r, this.props.appendTo || document.body) : r : null;
|
|
333
333
|
}
|
|
334
334
|
// Getters
|
|
335
335
|
get top() {
|
|
@@ -362,10 +362,10 @@ const w = 300, m = 300, S = 120, E = 100, d = 5, f = class f extends h.Component
|
|
|
362
362
|
return this.props.stage || this.state.stage;
|
|
363
363
|
}
|
|
364
364
|
getActionBar(s) {
|
|
365
|
-
return s.filter((t) => t && t.type ===
|
|
365
|
+
return s.filter((t) => t && t.type === F);
|
|
366
366
|
}
|
|
367
367
|
getContent(s) {
|
|
368
|
-
return s.filter((t) => t && t.type !==
|
|
368
|
+
return s.filter((t) => t && t.type !== F);
|
|
369
369
|
}
|
|
370
370
|
generateTitleId() {
|
|
371
371
|
return "window-title-" + this._id;
|
|
@@ -402,15 +402,15 @@ f.displayName = "Window", f.propTypes = {
|
|
|
402
402
|
autoFocus: !0
|
|
403
403
|
}, f.contextType = M;
|
|
404
404
|
let C = f;
|
|
405
|
-
const
|
|
405
|
+
const K = H(), P = z(
|
|
406
406
|
k(
|
|
407
|
-
|
|
407
|
+
K,
|
|
408
408
|
C
|
|
409
409
|
)
|
|
410
410
|
);
|
|
411
|
-
|
|
411
|
+
P.displayName = "KendoReactWindow";
|
|
412
412
|
export {
|
|
413
|
-
|
|
414
|
-
|
|
413
|
+
P as Window,
|
|
414
|
+
K as WindowPropsContext,
|
|
415
415
|
C as WindowWithoutContext
|
|
416
416
|
};
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-dom"),require("prop-types"),require("@progress/kendo-react-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-buttons","@progress/kendo-svg-icons","@progress/kendo-react-common","@progress/kendo-react-intl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).KendoReactDialogs={},t.React,t.ReactDOM,t.PropTypes,t.KendoReactButtons,t.KendoSvgIcons,t.KendoReactCommon,t.KendoReactIntl)}(this,(function(t,e,i,o,s,n,a,r){"use strict";function h(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var l=h(e),d=h(i);const c=({children:t,onCloseButtonClick:e,id:i,closeIcon:o})=>l.createElement("div",{className:"k-window-titlebar k-dialog-titlebar",id:i},l.createElement("span",{className:"k-window-title k-dialog-title"},t),o&&l.createElement("div",{className:"k-window-titlebar-actions k-dialog-titlebar-actions"},l.createElement(s.Button,{role:"button","aria-label":"Close",onClick:e,icon:"x",svgIcon:n.xIcon,fillMode:"flat",className:"k-window-titlebar-action k-dialog-titlebar-action"}))),p=t=>{const e={layout:"stretched",...t},{layout:i,children:o}=e,s=a.classNames("k-actions","k-actions-horizontal","k-window-actions k-dialog-actions",{[`k-actions-${i}`]:i});return l.createElement("div",{className:s},o)};p.propTypes={children:o.any,layout:o.oneOf(["start","center","end","stretched"])};const u="data-windowid",g=10002,m=a.createPropsContext(),w=l.forwardRef(((t,e)=>{const i=a.useZIndexContext(),o=i?i+2:g,s=l.useRef(null),n=l.useRef(null),r=l.useRef(a.getActiveElement(document)),h=a.usePropsContext(m,t),w=l.useMemo((()=>({...f,...h})),[h]),{title:E,width:C,height:v,children:S,minWidth:y,dir:b,style:k,themeColor:I,contentStyle:D,autoFocusedElement:T,appendTo:B,className:x,overlayStyle:L,modal:M=f.modal,closeIcon:N=f.closeIcon,autoFocus:R=f.autoFocus}=w,F=l.useCallback((()=>({props:w,element:n.current})),[w]);l.useImperativeHandle(s,F),l.useImperativeHandle(e,(()=>s.current));const z=l.useMemo((()=>l.Children.toArray(S).filter((t=>!l.isValidElement(t)||t.type!==p))),[S]),W=l.useMemo((()=>l.Children.toArray(S).filter((t=>l.isValidElement(t)&&t.type===p))),[S]),{_id:A,contentId:U,id:O}=l.useMemo((()=>{const t=w.id,e=`${null!=t?t:"accessibility"}-id`;return{_id:e,contentId:`dialog-content-${e}`,id:t||`dialog-title-${e}`}}),[w.id]),K=l.useCallback((()=>{if(n.current)if(R&&!T)n.current.focus();else if(!R&&T&&n.current){const t=n.current.querySelector(T);null==t||t.focus()}else{const t=[...a.FOCUSABLE_ELEMENTS].map((t=>t+":not(.k-dialog-titlebar *)"));a.focusFirstFocusableChild(n.current,t)}}),[R,T]);l.useEffect((()=>(K(),()=>{setTimeout((()=>{var t;!n.current&&r.current&&a.canUseDOM&&(document.contains(r.current)?r.current.focus():r.current.id&&(null==(t=document.getElementById(r.current.id))||t.focus()))}))})),[K]);const H=l.useCallback((t=>{t.preventDefault(),a.dispatchEvent(w.onClose,t,F(),void 0)}),[w.onClose]),Z=l.useCallback((t=>{t.keyCode===a.Keys.esc&&w.onClose&&(t.preventDefault(),H(t)),a.keepFocusInContainer(t,n.current)}),[w.onClose,H]),P=l.useMemo((()=>l.createElement(a.ZIndexContext.Provider,{value:o},l.createElement("div",{ref:n,[u]:A,className:"k-dialog-wrapper"+(x?" "+x:""),onKeyDown:Z,tabIndex:0,dir:b,style:{zIndex:o,...k}},M&&l.createElement("div",{className:"k-overlay",style:L}),l.createElement("div",{className:a.classNames("k-window k-dialog",{[`k-window-${I}`]:I}),role:"dialog","aria-labelledby":O,"aria-modal":!0,"aria-describedby":U,style:{width:C,height:v,minWidth:y}},E&&l.createElement(c,{closeIcon:N,onCloseButtonClick:H,id:O},E),l.createElement("div",{className:"k-window-content k-dialog-content",style:D,id:U},z),W)))),[o,A,x,Z,k,b,L,I,O,U,C,v,y,N,H,D,E,z,W,M]);return a.canUseDOM?null!==B?d.createPortal(P,B||document.body):P:null})),f={autoFocus:!1,modal:!0,closeIcon:!0},E={autoFocus:o.bool,autoFocusedElement:o.string,title:o.any,className:o.string,closeIcon:o.bool,modal:o.bool,overlayStyle:o.object,width:o.oneOfType([o.number,o.string]),height:o.oneOfType([o.number,o.string]),minWidth:o.oneOfType([o.number,o.string]),onClose:o.func,children:o.node,id:o.string,dir:o.string,style:o.object,contentStyle:o.object,appendTo:o.any,themeColor:o.oneOf(["primary","dark","light"])};w.displayName="KendoReactDialog",w.propTypes=E;var C=(t=>(t.DEFAULT="DEFAULT",t.FULLSCREEN="FULLSCREEN",t.MINIMIZED="MINIMIZED",t))(C||{});const v="dialogs.windowMaximizeButton",S="dialogs.windowMinimizeButton",y="dialogs.windowRestoreButton",b="dialogs.windowCloseButton",k={[v]:"maximize",[S]:"minimize",[y]:"restore",[b]:"close"},I=t=>{const{children:e,onCloseButtonClick:i,onMinimizeButtonClick:o,onFullScreenButtonClick:a,onRestoreButtonClick:h,onDoubleClick:d,stage:c,forwardedRef:p,id:u}=t,g=r.useLocalization(),m=t.minimizeButton?l.createElement(t.minimizeButton,{onClick:o,stage:c}):l.createElement(s.Button,{fillMode:"flat",icon:"window-minimize",svgIcon:n.windowMinimizeIcon,className:"k-window-titlebar-action",onClick:o,"aria-label":g.toLanguageString(S,k[S])}),w=t.maximizeButton?l.createElement(t.maximizeButton,{onClick:a,stage:c}):l.createElement(s.Button,{fillMode:"flat",icon:"window-maximize",svgIcon:n.windowIcon,className:"k-window-titlebar-action",onClick:a,"aria-label":g.toLanguageString(v,k[v])}),f=t.restoreButton?l.createElement(t.restoreButton,{onClick:h,stage:c}):l.createElement(s.Button,{fillMode:"flat",icon:"window-restore",svgIcon:n.windowRestoreIcon,className:"k-window-titlebar-action",onClick:h,"aria-label":g.toLanguageString(y,k[y])}),E=t.closeButton?l.createElement(t.closeButton,{onClick:i,stage:c}):l.createElement(s.Button,{fillMode:"flat",icon:"x",svgIcon:n.xIcon,className:"k-window-titlebar-action",onClick:i,"aria-label":g.toLanguageString(b,k[b])});return l.createElement("div",{className:"k-window-titlebar",style:{touchAction:"none"},ref:p,onDoubleClick:d},l.createElement("span",{className:"k-window-title",id:u},e||""),l.createElement("div",{className:"k-window-titlebar-actions"},c===C.DEFAULT&&m,c===C.DEFAULT&&w,c!==C.DEFAULT&&f,E))},D=l.forwardRef(((t,e)=>l.createElement(I,{...t,forwardedRef:e}))),T=["n","e","s","w","se","sw","ne","nw"];class B extends l.Component{render(){return l.createElement("div",{className:"k-resize-handles-wrapper"}," ",T.map(((t,e)=>l.createElement(a.Draggable,{key:e,onDrag:e=>{const{event:i}=e;i.originalEvent.preventDefault(),this.props.onResize(i,{end:!1,direction:t})},onRelease:e=>{const{event:i}=e;i.originalEvent.preventDefault(),this.props.onResize(i,{end:!0,direction:t})}},l.createElement("div",{className:"k-resize-handle k-resize-"+t,style:{display:"block",touchAction:"none",userSelect:"none"}})))))}}class x extends l.Component{shouldComponentUpdate(t){return t.shouldUpdateOnDrag||!t.isDragging}render(){return this.props.children}}const L=t=>{const e={layout:"end",...t},{layout:i,children:o}=e,s=a.classNames("k-actions","k-window-actions","k-actions-horizontal","k-hstack",{"k-justify-content-start":"start"===i,"k-justify-content-center":"center"===i,"k-justify-content-end":"end"===i,"k-justify-content-stretch":"stretched"===i});return l.createElement("div",{className:s},o)};L.propTypes={children:o.any,layout:o.oneOf(["start","center","end","stretched"])};const M=(t,e,i)=>{let o=t;if(e&&e.defaultView){const t=e.querySelectorAll(".k-window:not(.k-dialog), .k-dialog-wrapper");let s=!1;return t.forEach((t=>{const n=e.defaultView.getComputedStyle(t,null);if(t.getAttribute(u)!==i&&null!==n.zIndex){const t=parseInt(n.zIndex,10);t>=o&&(o=t,s=!0)}})),s?o+2:o}return o},N=class extends l.Component{constructor(t){super(t),this.context=0,this.draggable=null,this.offSetCoordinates={x:0,y:0},this.titleId=this.generateTitleId(),this.mounted=!1,this.activeElement=null,this.onKeyDown=t=>{if(this.props.modal&&a.keepFocusInContainer(t,this.element),t.target!==t.currentTarget)return;const e=this.props.minWidth||120,i=this.props.minHeight||100;if((t.metaKey||t.ctrlKey)&&this.props.resizable){switch(t.keyCode){case a.Keys.up:t.preventDefault(),i<=this.height-5&&this.setState({height:this.height-5});break;case a.Keys.down:t.preventDefault(),this.setState({height:this.height+5});break;case a.Keys.left:e<=this.width-5&&this.setState({width:this.width-5});break;case a.Keys.right:this.setState({width:this.width+5});break;default:return}this.dispatchMoveEvent(this.props.onResize,t,!1,void 0)}else if(t.altKey)switch(t.keyCode){case a.Keys.up:this.windowStage===C.MINIMIZED?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.DEFAULT})):this.windowStage===C.DEFAULT&&(this.handleFullscreen(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.FULLSCREEN}));break;case a.Keys.down:this.windowStage===C.FULLSCREEN?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.DEFAULT})):this.windowStage===C.DEFAULT&&(this.handleMinimize(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.MINIMIZED}))}else{if(!t.ctrlKey)switch(t.keyCode){case a.Keys.esc:return void(this.props.onClose&&this.handleCloseWindow(t));case a.Keys.up:this.setState((t=>({top:t.top-5})));break;case a.Keys.down:this.setState((t=>({top:t.top+5})));break;case a.Keys.left:this.setState((t=>({left:t.left-5})));break;case a.Keys.right:this.setState((t=>({left:t.left+5})));break;default:return}this.dispatchMoveEvent(this.props.onMove,t,!1,void 0)}},this.onPress=t=>{const e=t.event;this.windowCoordinatesState.differenceLeft=e.pageX-this.left,this.windowCoordinatesState.differenceTop=e.pageY-this.top},this.onDrag=t=>{const e=t.event;e.originalEvent.preventDefault(),this.windowStage!==C.FULLSCREEN&&this.props.draggable&&(this.setState({top:Math.max(e.pageY-this.windowCoordinatesState.differenceTop,0),left:e.pageX-this.windowCoordinatesState.differenceLeft,isDragging:!0}),this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!1))},this.onRelease=t=>{const e=t.event;this.windowStage!==C.FULLSCREEN&&this.props.draggable&&this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!0),this.setState({isDragging:!1})},this.onFocus=()=>{this._blurTimeout?(clearTimeout(this._blurTimeout),this._blurTimeout=void 0):this.setState({focused:!0,zIndex:M(this.getCurrentZIndex(),this.getDocument(),this._id)})},this.onBlur=()=>{clearTimeout(this._blurTimeout);const t=this.getWindow();t&&(this._blurTimeout=t.setTimeout((()=>{this.mounted&&this.setState({focused:!1}),this._blurTimeout=void 0})))},this.getInitialTop=()=>{if(void 0!==this.props.top)return this.props.top;if(void 0!==this.props.initialTop)return this.props.initialTop;let t=300;if(void 0!==this.props.height?t=this.props.height:void 0!==this.props.initialHeight&&(t=this.props.initialHeight),this.props.appendTo)return this.props.appendTo.offsetHeight/2-t/2;const e=this.getWindow();return e?e.innerHeight/2-t/2:0},this.getInitialLeft=()=>{if(void 0!==this.props.left)return this.props.left;if(void 0!==this.props.initialLeft)return this.props.initialLeft;let t=300;if(void 0!==this.props.width?t=this.props.width:void 0!==this.props.initialWidth&&(t=this.props.initialWidth),this.props.appendTo)return this.props.appendTo.offsetWidth/2-t/2;const e=this.getWindow();return e?e.innerWidth/2-t/2:0},this.getInitialWidth=()=>{let t=300;return void 0!==this.props.width?t=this.props.width:void 0!==this.props.initialWidth&&(t=this.props.initialWidth),t},this.getInitialHeight=()=>{let t=300;return void 0!==this.props.height?t=this.props.height:void 0!==this.props.initialHeight&&(t=this.props.initialHeight),t},this.handleMinimize=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height,this.setState({stage:C.MINIMIZED,height:0}),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.MINIMIZED})},this.handleFullscreen=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height;const e=this.getWindow(),i=e?e.innerWidth:0,o=e?e.innerHeight:0;this.setState({left:0,top:0,width:this.props.appendTo?this.props.appendTo.offsetWidth:i,height:this.props.appendTo?this.props.appendTo.offsetHeight:o,stage:C.FULLSCREEN}),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.FULLSCREEN})},this.handleRestore=t=>{t.preventDefault(),this.windowStage===C.FULLSCREEN?this.setState({stage:C.DEFAULT,left:this.windowCoordinatesState.leftBeforeAction,top:this.windowCoordinatesState.topBeforeAction,width:this.windowCoordinatesState.widthBeforeAction,height:this.windowCoordinatesState.heightBeforeAction}):this.windowStage===C.MINIMIZED&&this.setState({stage:C.DEFAULT,height:this.windowCoordinatesState.heightBeforeAction}),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.DEFAULT})},this.handleCloseWindow=t=>{t.preventDefault(),a.dispatchEvent(this.props.onClose,t,this,{state:void 0})},this.handleDoubleClick=t=>{this.windowStage===C.FULLSCREEN||this.windowStage===C.MINIMIZED?this.handleRestore(t):this.handleFullscreen(t)},this.handleResize=(t,e)=>{const i=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,o=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,s=this.width,n=this.height,a=this.props.minWidth||120,r=this.props.minHeight||100,h=this.top-o,l=this.left-i,d=i-this.left,c=o-this.top,p=Object.assign({},this.state,{isDragging:!e.end});e.direction.indexOf("n")>=0&&r-(n+h)<0&&(this.top>0&&(p.height=n+h),p.top=o),e.direction.indexOf("s")>=0&&r-c<0&&(p.height=c),e.direction.indexOf("w")>=0&&a-(s+l)<0&&(this.left>0&&(p.width=s+l),p.left=i),e.direction.indexOf("e")>=0&&a-d<0&&(p.width=d),this.setState(p),this.dispatchMoveEvent(this.props.onResize,t,!0,e.end)},this.dispatchMoveEvent=(t,e,i,o)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:i,end:o,target:this,left:this.state.left,top:this.state.top,width:this.state.width,hight:this.state.height,height:this.state.height})},this.handleBrowserWindowResize=()=>{if(this.windowStage===C.FULLSCREEN){const t=this.getWindow(),e=t?t.innerWidth:0,i=t?t.innerHeight:0;this.setState({width:this.props.appendTo?this.props.appendTo.offsetWidth:e,height:this.props.appendTo?this.props.appendTo.offsetHeight:i})}},this.getCurrentZIndex=()=>this.state&&void 0!==this.context?this.state.zIndex>(this.context?this.context+2:0)?this.state.zIndex:this.context+2:this.context?this.context:g,this.getDocument=()=>{const t=a.canUseDOM?document:null;return this.props.appendTo?this.props.appendTo.ownerDocument:t},this.getWindow=()=>{const t=this.getDocument();return t&&t.defaultView},this.state={stage:this.props.stage||C.DEFAULT,isDragging:!1,top:0,left:0,width:300,height:300,focused:!0,zIndex:g},a.canUseDOM&&(this.activeElement=document.activeElement)}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){this.element&&this.props.autoFocus&&this.element.focus({preventScroll:!0});const t=this.getWindow();t&&t.addEventListener("resize",this.handleBrowserWindowResize),this.setState({stage:this.props.stage||C.DEFAULT,isDragging:!1,top:this.getInitialTop(),left:this.getInitialLeft(),width:this.getInitialWidth(),height:this.getInitialHeight(),focused:!0,zIndex:M(this.getCurrentZIndex(),this.getDocument(),this._id)}),this.windowCoordinatesState={leftBeforeAction:this.getInitialLeft(),topBeforeAction:this.getInitialTop(),widthBeforeAction:this.getInitialWidth(),heightBeforeAction:this.getInitialHeight()};const e=this.getDocument();if(this.props.appendTo&&e){const t=this.props.appendTo.getBoundingClientRect(),i=e.body.getBoundingClientRect();this.offSetCoordinates.x=t.left-i.left,this.offSetCoordinates.y=t.top-i.top}this.mounted=!0}componentWillUnmount(){const t=this.getWindow();t&&t.removeEventListener("resize",this.handleBrowserWindowResize),this.mounted=!1,setTimeout((()=>{var t;!this.element&&this.activeElement&&a.canUseDOM&&(document.contains(this.activeElement)?this.activeElement.focus({preventScroll:!0}):this.activeElement.id&&(null==(t=document.getElementById(this.activeElement.id))||t.focus({preventScroll:!0})))}))}componentDidUpdate(t){this.props.left&&t.left!==this.props.left&&this.setState({left:this.props.left}),this.props.top&&t.top!==this.props.top&&this.setState({top:this.props.top});const e=this.getDocument();if(this.props.appendTo&&e){const t=this.props.appendTo.getBoundingClientRect(),i=e.body.getBoundingClientRect();this.offSetCoordinates.x=t.left-i.left,this.offSetCoordinates.y=t.top-i.top}this.mounted=!0}render(){const t=l.Children.toArray(this.props.children),e=this.getContent(t),i=this.getActionBar(t),o=this.getCurrentZIndex(),s=a.classNames("k-window",this.props.className,{[`k-window-${this.props.themeColor}`]:this.props.themeColor,"k-window-minimized":"MINIMIZED"===this.state.stage,"k-focus":this.state.focused}),n=l.createElement(a.ZIndexContext.Provider,{value:o},l.createElement(l.Fragment,null,this.props.modal&&l.createElement("div",{className:"k-overlay",style:{zIndex:o,...this.props.overlayStyle}}),l.createElement("div",{id:this.props.id,[u]:this._id,tabIndex:0,role:"dialog","aria-labelledby":this.titleId,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,ref:t=>{this.windowElement=t,this.element=t},className:s,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:o,...this.props.style}},l.createElement(x,{shouldUpdateOnDrag:this.props.shouldUpdateOnDrag||!1,isDragging:this.state.isDragging},l.createElement(a.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,autoScroll:!1,ref:t=>{this.draggable=t}},l.createElement(D,{stage:this.windowStage,onDoubleClick:this.props.doubleClickStageChange?this.handleDoubleClick:void 0,onMinimizeButtonClick:this.handleMinimize,onFullScreenButtonClick:this.handleFullscreen,onRestoreButtonClick:this.handleRestore,onCloseButtonClick:this.handleCloseWindow,closeButton:this.props.closeButton,minimizeButton:this.props.minimizeButton,maximizeButton:this.props.maximizeButton,restoreButton:this.props.restoreButton,id:this.titleId},this.props.title)),this.windowStage!==C.MINIMIZED?l.createElement(l.Fragment,null,l.createElement("div",{className:"k-window-content"},e),i):null,this.windowStage===C.DEFAULT&&this.props.resizable?l.createElement(B,{onResize:this.handleResize}):null))));return a.canUseDOM?null!==this.props.appendTo?d.createPortal(n,this.props.appendTo||document.body):n:null}get top(){return this.windowStage!==C.FULLSCREEN?Math.max(this.props.top||this.state.top,0):0}get left(){return this.windowStage!==C.FULLSCREEN?Math.max(this.props.left||this.state.left,0):0}get width(){let t=this.props.width||this.state.width;if(this.windowStage===C.FULLSCREEN){if(this.props.appendTo)return t=this.props.appendTo.offsetWidth,t;const e=this.getWindow();t=e?e.innerWidth:0}return t}get height(){let t=this.props.height||this.state.height;if(this.windowStage===C.FULLSCREEN){if(this.props.appendTo)return t=this.props.appendTo.offsetHeight,t;const e=this.getWindow();t=e?e.innerHeight:0}else this.windowStage===C.MINIMIZED&&(t=0);return t}get windowStage(){return this.props.stage||this.state.stage}getActionBar(t){return t.filter((t=>t&&t.type===L))}getContent(t){return t.filter((t=>t&&t.type!==L))}generateTitleId(){return"window-title-"+this._id}};N.displayName="Window",N.propTypes={width:o.number,height:o.number,left:o.number,top:o.number,initialWidth:o.number,initialHeight:o.number,initialLeft:o.number,initialTop:o.number,minWidth:o.number,minHeight:o.number,resizable:o.bool,draggable:o.bool,title:o.any,shouldUpdateOnDrag:o.bool,stage:o.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),className:o.string,id:o.string,style:o.object,overlayStyle:o.object,autoFocus:o.bool},N.defaultProps={minWidth:120,minHeight:100,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},N.contextType=a.ZIndexContext;let R=N;const F=a.createPropsContext(),z=a.withIdHOC(a.withPropsContext(F,R));z.displayName="KendoReactWindow",t.Dialog=w,t.DialogActionsBar=p,t.DialogPropsContext=m,t.Window=z,t.WindowActionsBar=L,t.WindowPropsContext=F,t.WindowWithoutContext=R}));
|
|
15
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-dom"),require("prop-types"),require("@progress/kendo-react-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-buttons","@progress/kendo-svg-icons","@progress/kendo-react-common","@progress/kendo-react-intl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).KendoReactDialogs={},t.React,t.ReactDOM,t.PropTypes,t.KendoReactButtons,t.KendoSvgIcons,t.KendoReactCommon,t.KendoReactIntl)}(this,(function(t,e,i,o,s,n,a,r){"use strict";function h(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var l=h(e),d=h(i);const p=({children:t,onCloseButtonClick:e,id:i,closeIcon:o})=>l.createElement("div",{className:"k-window-titlebar k-dialog-titlebar",id:i},l.createElement("span",{className:"k-window-title k-dialog-title"},t),o&&l.createElement("div",{className:"k-window-titlebar-actions k-dialog-titlebar-actions"},l.createElement(s.Button,{role:"button","aria-label":"Close",onClick:e,icon:"x",svgIcon:n.xIcon,fillMode:"flat",className:"k-window-titlebar-action k-dialog-titlebar-action"}))),c=t=>{const e={layout:"stretched",...t},{layout:i,children:o}=e,s=a.classNames("k-actions","k-actions-horizontal","k-window-actions k-dialog-actions",{[`k-actions-${i}`]:i});return l.createElement("div",{className:s},o)};c.propTypes={children:o.any,layout:o.oneOf(["start","center","end","stretched"])};const u="data-windowid",g=10002,f=a.createPropsContext(),m=l.forwardRef(((t,e)=>{const i=a.useZIndexContext(),o=i?i+2:g,s=l.useRef(null),n=l.useRef(null),r=l.useRef(a.getActiveElement(document)),h=a.usePropsContext(f,t),m=l.useMemo((()=>({...w,...h})),[h]),{title:E,width:C,height:v,children:S,minWidth:y,dir:b,style:k,themeColor:I,contentStyle:D,autoFocusedElement:T,appendTo:B,className:L,overlayStyle:x,modal:M=w.modal,closeIcon:N=w.closeIcon,autoFocus:R=w.autoFocus}=m,F=l.useCallback((()=>({props:m,element:n.current})),[m]);l.useImperativeHandle(s,F),l.useImperativeHandle(e,(()=>s.current));const z=l.useMemo((()=>l.Children.toArray(S).filter((t=>!l.isValidElement(t)||t.type!==c))),[S]),W=l.useMemo((()=>l.Children.toArray(S).filter((t=>l.isValidElement(t)&&t.type===c))),[S]),{_id:A,contentId:U,id:O}=l.useMemo((()=>{const t=m.id,e=`${null!=t?t:"accessibility"}-id`;return{_id:e,contentId:`dialog-content-${e}`,id:t||`dialog-title-${e}`}}),[m.id]),K=l.useCallback((()=>{if(n.current)if(R&&!T)n.current.focus();else if(!R&&T&&n.current){const t=n.current.querySelector(T);null==t||t.focus()}else{const t=[...a.FOCUSABLE_ELEMENTS].map((t=>t+":not(.k-dialog-titlebar *)"));a.focusFirstFocusableChild(n.current,t)}}),[R,T]);l.useEffect((()=>(K(),()=>{setTimeout((()=>{var t;!n.current&&r.current&&a.canUseDOM&&(document.contains(r.current)?r.current.focus():r.current.id&&(null==(t=document.getElementById(r.current.id))||t.focus()))}))})),[K]);const H=l.useCallback((t=>{t.preventDefault(),a.dispatchEvent(m.onClose,t,F(),void 0)}),[m.onClose]),Z=l.useCallback((t=>{t.keyCode===a.Keys.esc&&m.onClose&&(t.preventDefault(),H(t)),a.keepFocusInContainer(t,n.current)}),[m.onClose,H]),P=l.useMemo((()=>l.createElement(a.ZIndexContext.Provider,{value:o},l.createElement("div",{ref:n,[u]:A,className:"k-dialog-wrapper"+(L?" "+L:""),onKeyDown:Z,tabIndex:0,dir:b,style:{zIndex:o,...k}},M&&l.createElement("div",{className:"k-overlay",style:x}),l.createElement("div",{className:a.classNames("k-window k-dialog",{[`k-window-${I}`]:I}),role:"dialog","aria-labelledby":O,"aria-modal":!0,"aria-describedby":U,style:{width:C,height:v,minWidth:y}},E&&l.createElement(p,{closeIcon:N,onCloseButtonClick:H,id:O},E),l.createElement("div",{className:"k-window-content k-dialog-content",style:D,id:U},z),W)))),[o,A,L,Z,k,b,x,I,O,U,C,v,y,N,H,D,E,z,W,M]);return a.canUseDOM?null!==B?d.createPortal(P,B||document.body):P:null})),w={autoFocus:!1,modal:!0,closeIcon:!0},E={autoFocus:o.bool,autoFocusedElement:o.string,title:o.any,className:o.string,closeIcon:o.bool,modal:o.bool,overlayStyle:o.object,width:o.oneOfType([o.number,o.string]),height:o.oneOfType([o.number,o.string]),minWidth:o.oneOfType([o.number,o.string]),onClose:o.func,children:o.node,id:o.string,dir:o.string,style:o.object,contentStyle:o.object,appendTo:o.any,themeColor:o.oneOf(["primary","dark","light"])};m.displayName="KendoReactDialog",m.propTypes=E;var C=(t=>(t.DEFAULT="DEFAULT",t.FULLSCREEN="FULLSCREEN",t.MINIMIZED="MINIMIZED",t))(C||{});const v="dialogs.windowMaximizeButton",S="dialogs.windowMinimizeButton",y="dialogs.windowRestoreButton",b="dialogs.windowCloseButton",k={[v]:"maximize",[S]:"minimize",[y]:"restore",[b]:"close"},I=t=>{const{children:e,onCloseButtonClick:i,onMinimizeButtonClick:o,onFullScreenButtonClick:a,onRestoreButtonClick:h,onDoubleClick:d,stage:p,forwardedRef:c,id:u}=t,g=r.useLocalization(),f=t.minimizeButton?l.createElement(t.minimizeButton,{onClick:o,stage:p}):l.createElement(s.Button,{fillMode:"flat",icon:"window-minimize",svgIcon:n.windowMinimizeIcon,className:"k-window-titlebar-action",onClick:o,"aria-label":g.toLanguageString(S,k[S])}),m=t.maximizeButton?l.createElement(t.maximizeButton,{onClick:a,stage:p}):l.createElement(s.Button,{fillMode:"flat",icon:"window-maximize",svgIcon:n.windowIcon,className:"k-window-titlebar-action",onClick:a,"aria-label":g.toLanguageString(v,k[v])}),w=t.restoreButton?l.createElement(t.restoreButton,{onClick:h,stage:p}):l.createElement(s.Button,{fillMode:"flat",icon:"window-restore",svgIcon:n.windowRestoreIcon,className:"k-window-titlebar-action",onClick:h,"aria-label":g.toLanguageString(y,k[y])}),E=t.closeButton?l.createElement(t.closeButton,{onClick:i,stage:p}):l.createElement(s.Button,{fillMode:"flat",icon:"x",svgIcon:n.xIcon,className:"k-window-titlebar-action",onClick:i,"aria-label":g.toLanguageString(b,k[b])});return l.createElement("div",{className:"k-window-titlebar",style:{touchAction:"none"},ref:c,onDoubleClick:d},l.createElement("span",{className:"k-window-title",id:u},e||""),l.createElement("div",{className:"k-window-titlebar-actions"},p===C.DEFAULT&&f,p===C.DEFAULT&&m,p!==C.DEFAULT&&w,E))},D=l.forwardRef(((t,e)=>l.createElement(I,{...t,forwardedRef:e}))),T=["n","e","s","w","se","sw","ne","nw"];class B extends l.Component{render(){return l.createElement("div",{className:"k-resize-handles-wrapper"}," ",T.map(((t,e)=>l.createElement(a.Draggable,{key:e,onDrag:e=>{const{event:i}=e;i.originalEvent.preventDefault(),this.props.onResize(i,{end:!1,direction:t})},onRelease:e=>{const{event:i}=e;i.originalEvent.preventDefault(),this.props.onResize(i,{end:!0,direction:t})}},l.createElement("div",{className:"k-resize-handle k-resize-"+t,style:{display:"block",touchAction:"none",userSelect:"none"}})))))}}class L extends l.Component{shouldComponentUpdate(t){return t.shouldUpdateOnDrag||!t.isDragging}render(){return this.props.children}}const x=t=>{const e={layout:"end",...t},{layout:i,children:o}=e,s=a.classNames("k-actions","k-window-actions","k-actions-horizontal","k-hstack",{"k-justify-content-start":"start"===i,"k-justify-content-center":"center"===i,"k-justify-content-end":"end"===i,"k-justify-content-stretch":"stretched"===i});return l.createElement("div",{className:s},o)};x.propTypes={children:o.any,layout:o.oneOf(["start","center","end","stretched"])};const M=(t,e,i)=>{let o=t;if(e&&e.defaultView){const t=e.querySelectorAll(".k-window:not(.k-dialog), .k-dialog-wrapper");let s=!1;return t.forEach((t=>{const n=e.defaultView.getComputedStyle(t,null);if(t.getAttribute(u)!==i&&null!==n.zIndex){const t=parseInt(n.zIndex,10);t>=o&&(o=t,s=!0)}})),s?o+2:o}return o},N=class extends l.Component{constructor(t){super(t),this.context=0,this.draggable=null,this.offSetCoordinates={x:0,y:0},this.titleId=this.generateTitleId(),this.mounted=!1,this.activeElement=null,this.onKeyDown=t=>{if(this.props.modal&&a.keepFocusInContainer(t,this.element),t.target!==t.currentTarget)return;const e=this.props.minWidth||120,i=this.props.minHeight||100;if((t.metaKey||t.ctrlKey)&&this.props.resizable){switch(t.keyCode){case a.Keys.up:t.preventDefault(),i<=this.height-5&&this.setState({height:this.height-5});break;case a.Keys.down:t.preventDefault(),this.setState({height:this.height+5});break;case a.Keys.left:e<=this.width-5&&this.setState({width:this.width-5});break;case a.Keys.right:this.setState({width:this.width+5});break;default:return}this.dispatchMoveEvent(this.props.onResize,t,!1,void 0)}else if(t.altKey)switch(t.keyCode){case a.Keys.up:this.windowStage===C.MINIMIZED?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.DEFAULT})):this.windowStage===C.DEFAULT&&(this.handleFullscreen(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.FULLSCREEN}));break;case a.Keys.down:this.windowStage===C.FULLSCREEN?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.DEFAULT})):this.windowStage===C.DEFAULT&&(this.handleMinimize(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.MINIMIZED}))}else{if(!t.ctrlKey)switch(t.keyCode){case a.Keys.esc:return void(this.props.onClose&&this.handleCloseWindow(t));case a.Keys.up:this.setState((t=>({top:t.top-5})));break;case a.Keys.down:this.setState((t=>({top:t.top+5})));break;case a.Keys.left:this.setState((t=>({left:t.left-5})));break;case a.Keys.right:this.setState((t=>({left:t.left+5})));break;default:return}this.dispatchMoveEvent(this.props.onMove,t,!1,void 0)}},this.onPress=t=>{const e=t.event;this.windowCoordinatesState.differenceLeft=e.pageX-this.left,this.windowCoordinatesState.differenceTop=e.pageY-this.top},this.onDrag=t=>{const e=t.event;e.originalEvent.preventDefault(),this.windowStage!==C.FULLSCREEN&&this.props.draggable&&(this.setState({top:Math.max(e.pageY-this.windowCoordinatesState.differenceTop,0),left:e.pageX-this.windowCoordinatesState.differenceLeft,isDragging:!0}),this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!1))},this.onRelease=t=>{const e=t.event;this.windowStage!==C.FULLSCREEN&&this.props.draggable&&this.props.onMove&&this.dispatchMoveEvent(this.props.onMove,e,!0,!0),this.setState({isDragging:!1})},this.onFocus=()=>{this._blurTimeout?(clearTimeout(this._blurTimeout),this._blurTimeout=void 0):this.setState({focused:!0,zIndex:M(this.getCurrentZIndex(),this.getDocument(),this._id)})},this.onBlur=()=>{clearTimeout(this._blurTimeout);const t=this.getWindow();t&&(this._blurTimeout=t.setTimeout((()=>{this.mounted&&this.setState({focused:!1}),this._blurTimeout=void 0})))},this.getInitialTop=()=>{if(void 0!==this.props.top)return this.props.top;if(void 0!==this.props.initialTop)return this.props.initialTop;let t=300;if(void 0!==this.props.height?t=this.props.height:void 0!==this.props.initialHeight&&(t=this.props.initialHeight),this.props.appendTo)return this.props.appendTo.offsetHeight/2-t/2;const e=this.getWindow();return e?e.innerHeight/2-t/2:0},this.getInitialLeft=()=>{if(void 0!==this.props.left)return this.props.left;if(void 0!==this.props.initialLeft)return this.props.initialLeft;let t=300;if(void 0!==this.props.width?t=this.props.width:void 0!==this.props.initialWidth&&(t=this.props.initialWidth),this.props.appendTo)return this.props.appendTo.offsetWidth/2-t/2;const e=this.getWindow();return e?e.innerWidth/2-t/2:0},this.getInitialWidth=()=>{let t=300;return void 0!==this.props.width?t=this.props.width:void 0!==this.props.initialWidth&&(t=this.props.initialWidth),t},this.getInitialHeight=()=>{let t=300;return void 0!==this.props.height?t=this.props.height:void 0!==this.props.initialHeight&&(t=this.props.initialHeight),t},this.handleMinimize=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height,this.setState({stage:C.MINIMIZED,height:0}),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.MINIMIZED})},this.handleFullscreen=t=>{t.preventDefault(),this.windowCoordinatesState.leftBeforeAction=this.left,this.windowCoordinatesState.topBeforeAction=this.top,this.windowCoordinatesState.widthBeforeAction=this.width,this.windowCoordinatesState.heightBeforeAction=this.height;const e=this.getWindow(),i=e?e.innerWidth:0,o=e?e.innerHeight:0;this.setState({left:0,top:0,width:this.props.appendTo?this.props.appendTo.offsetWidth:i,height:this.props.appendTo?this.props.appendTo.offsetHeight:o,stage:C.FULLSCREEN}),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.FULLSCREEN})},this.handleRestore=t=>{t.preventDefault(),this.windowStage===C.FULLSCREEN?this.setState({stage:C.DEFAULT,left:this.windowCoordinatesState.leftBeforeAction,top:this.windowCoordinatesState.topBeforeAction,width:this.windowCoordinatesState.widthBeforeAction,height:this.windowCoordinatesState.heightBeforeAction}):this.windowStage===C.MINIMIZED&&this.setState({stage:C.DEFAULT,height:this.windowCoordinatesState.heightBeforeAction}),a.dispatchEvent(this.props.onStageChange,t,this,{state:C.DEFAULT})},this.handleCloseWindow=t=>{t.preventDefault(),a.dispatchEvent(this.props.onClose,t,this,{state:void 0})},this.handleDoubleClick=t=>{this.windowStage===C.FULLSCREEN||this.windowStage===C.MINIMIZED?this.handleRestore(t):this.handleFullscreen(t)},this.handleResize=(t,e)=>{const i=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,o=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,s=this.width,n=this.height,a=this.props.minWidth||120,r=this.props.minHeight||100,h=this.top-o,l=this.left-i,d=i-this.left,p=o-this.top,c=Object.assign({},this.state,{isDragging:!e.end});e.direction.indexOf("n")>=0&&r-(n+h)<0&&(this.top>0&&(c.height=n+h),c.top=o),e.direction.indexOf("s")>=0&&r-p<0&&(c.height=p),e.direction.indexOf("w")>=0&&a-(s+l)<0&&(this.left>0&&(c.width=s+l),c.left=i),e.direction.indexOf("e")>=0&&a-d<0&&(c.width=d),this.setState(c),this.dispatchMoveEvent(this.props.onResize,t,!0,e.end)},this.dispatchMoveEvent=(t,e,i,o)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:i,end:o,target:this,left:this.state.left,top:this.state.top,width:this.state.width,hight:this.state.height,height:this.state.height})},this.handleBrowserWindowResize=()=>{if(this.windowStage===C.FULLSCREEN){const t=this.getWindow(),e=t?t.innerWidth:0,i=t?t.innerHeight:0;this.setState({width:this.props.appendTo?this.props.appendTo.offsetWidth:e,height:this.props.appendTo?this.props.appendTo.offsetHeight:i})}},this.getCurrentZIndex=()=>this.state&&void 0!==this.context?this.state.zIndex>(this.context?this.context+2:0)?this.state.zIndex:this.context+2:this.context?this.context:g,this.getDocument=()=>{const t=a.canUseDOM?document:null;return this.props.appendTo?this.props.appendTo.ownerDocument:t},this.getWindow=()=>{const t=this.getDocument();return t&&t.defaultView},this.state={stage:this.props.stage||C.DEFAULT,isDragging:!1,top:0,left:0,width:300,height:300,focused:!0,zIndex:g},a.canUseDOM&&(this.activeElement=document.activeElement)}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){this.element&&this.props.autoFocus&&this.element.focus({preventScroll:!0});const t=this.getWindow();t&&t.addEventListener("resize",this.handleBrowserWindowResize),this.setState({stage:this.props.stage||C.DEFAULT,isDragging:!1,top:this.getInitialTop(),left:this.getInitialLeft(),width:this.getInitialWidth(),height:this.getInitialHeight(),focused:!0,zIndex:M(this.getCurrentZIndex(),this.getDocument(),this._id)}),this.windowCoordinatesState={leftBeforeAction:this.getInitialLeft(),topBeforeAction:this.getInitialTop(),widthBeforeAction:this.getInitialWidth(),heightBeforeAction:this.getInitialHeight()};const e=this.getDocument();if(this.props.appendTo&&e){const t=this.props.appendTo.getBoundingClientRect(),i=e.body.getBoundingClientRect();this.offSetCoordinates.x=t.left-i.left,this.offSetCoordinates.y=t.top-i.top}this.mounted=!0}componentWillUnmount(){const t=this.getWindow();t&&t.removeEventListener("resize",this.handleBrowserWindowResize),this.mounted=!1,setTimeout((()=>{var t;!this.element&&this.activeElement&&a.canUseDOM&&(document.contains(this.activeElement)?this.activeElement.focus({preventScroll:!0}):this.activeElement.id&&(null==(t=document.getElementById(this.activeElement.id))||t.focus({preventScroll:!0})))}))}componentDidUpdate(t){this.props.left&&t.left!==this.props.left&&this.setState({left:this.props.left}),this.props.top&&t.top!==this.props.top&&this.setState({top:this.props.top}),this.props.initialLeft&&t.initialLeft!==this.props.initialLeft&&this.setState({left:this.props.initialLeft}),this.props.initialTop&&t.initialTop!==this.props.initialTop&&this.setState({top:this.props.initialTop});const e=this.getDocument();if(this.props.appendTo&&e){const t=this.props.appendTo.getBoundingClientRect(),i=e.body.getBoundingClientRect();this.offSetCoordinates.x=t.left-i.left,this.offSetCoordinates.y=t.top-i.top}this.mounted=!0}render(){const t=l.Children.toArray(this.props.children),e=this.getContent(t),i=this.getActionBar(t),o=this.getCurrentZIndex(),s=a.classNames("k-window",this.props.className,{[`k-window-${this.props.themeColor}`]:this.props.themeColor,"k-window-minimized":"MINIMIZED"===this.state.stage,"k-focus":this.state.focused}),n=l.createElement(a.ZIndexContext.Provider,{value:o},l.createElement(l.Fragment,null,this.props.modal&&l.createElement("div",{className:"k-overlay",style:{zIndex:o,...this.props.overlayStyle}}),l.createElement("div",{id:this.props.id,[u]:this._id,tabIndex:0,role:"dialog","aria-labelledby":this.titleId,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,ref:t=>{this.windowElement=t,this.element=t},className:s,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:o,...this.props.style}},l.createElement(L,{shouldUpdateOnDrag:this.props.shouldUpdateOnDrag||!1,isDragging:this.state.isDragging},l.createElement(a.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,autoScroll:!1,ref:t=>{this.draggable=t}},l.createElement(D,{stage:this.windowStage,onDoubleClick:this.props.doubleClickStageChange?this.handleDoubleClick:void 0,onMinimizeButtonClick:this.handleMinimize,onFullScreenButtonClick:this.handleFullscreen,onRestoreButtonClick:this.handleRestore,onCloseButtonClick:this.handleCloseWindow,closeButton:this.props.closeButton,minimizeButton:this.props.minimizeButton,maximizeButton:this.props.maximizeButton,restoreButton:this.props.restoreButton,id:this.titleId},this.props.title)),this.windowStage!==C.MINIMIZED?l.createElement(l.Fragment,null,l.createElement("div",{className:"k-window-content"},e),i):null,this.windowStage===C.DEFAULT&&this.props.resizable?l.createElement(B,{onResize:this.handleResize}):null))));return a.canUseDOM?null!==this.props.appendTo?d.createPortal(n,this.props.appendTo||document.body):n:null}get top(){return this.windowStage!==C.FULLSCREEN?Math.max(this.props.top||this.state.top,0):0}get left(){return this.windowStage!==C.FULLSCREEN?Math.max(this.props.left||this.state.left,0):0}get width(){let t=this.props.width||this.state.width;if(this.windowStage===C.FULLSCREEN){if(this.props.appendTo)return t=this.props.appendTo.offsetWidth,t;const e=this.getWindow();t=e?e.innerWidth:0}return t}get height(){let t=this.props.height||this.state.height;if(this.windowStage===C.FULLSCREEN){if(this.props.appendTo)return t=this.props.appendTo.offsetHeight,t;const e=this.getWindow();t=e?e.innerHeight:0}else this.windowStage===C.MINIMIZED&&(t=0);return t}get windowStage(){return this.props.stage||this.state.stage}getActionBar(t){return t.filter((t=>t&&t.type===x))}getContent(t){return t.filter((t=>t&&t.type!==x))}generateTitleId(){return"window-title-"+this._id}};N.displayName="Window",N.propTypes={width:o.number,height:o.number,left:o.number,top:o.number,initialWidth:o.number,initialHeight:o.number,initialLeft:o.number,initialTop:o.number,minWidth:o.number,minHeight:o.number,resizable:o.bool,draggable:o.bool,title:o.any,shouldUpdateOnDrag:o.bool,stage:o.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),className:o.string,id:o.string,style:o.object,overlayStyle:o.object,autoFocus:o.bool},N.defaultProps={minWidth:120,minHeight:100,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},N.contextType=a.ZIndexContext;let R=N;const F=a.createPropsContext(),z=a.withIdHOC(a.withPropsContext(F,R));z.displayName="KendoReactWindow",t.Dialog=m,t.DialogActionsBar=c,t.DialogPropsContext=f,t.Window=z,t.WindowActionsBar=x,t.WindowPropsContext=F,t.WindowWithoutContext=R}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-dialogs",
|
|
3
|
-
"version": "11.4.0-develop.
|
|
3
|
+
"version": "11.4.0-develop.3",
|
|
4
4
|
"description": "React Dialogs provide modal and non-modal windows for showing additional information to the user. KendoReact Dialogs package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-licensing": "^1.6.0",
|
|
29
|
-
"@progress/kendo-react-buttons": "11.4.0-develop.
|
|
30
|
-
"@progress/kendo-react-common": "11.4.0-develop.
|
|
31
|
-
"@progress/kendo-react-intl": "11.4.0-develop.
|
|
29
|
+
"@progress/kendo-react-buttons": "11.4.0-develop.3",
|
|
30
|
+
"@progress/kendo-react-common": "11.4.0-develop.3",
|
|
31
|
+
"@progress/kendo-react-intl": "11.4.0-develop.3",
|
|
32
32
|
"@progress/kendo-svg-icons": "^4.0.0",
|
|
33
33
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
34
34
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|