@progress/kendo-react-dialogs 13.4.0-develop.2 → 13.4.0-develop.4

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/Dialog.mjs CHANGED
@@ -44,14 +44,14 @@ const ce = V(), $ = t.forwardRef((j, z) => {
44
44
  [r]
45
45
  );
46
46
  t.useImperativeHandle(E, N), t.useImperativeHandle(z, () => E.current);
47
- const O = t.useMemo(() => t.Children.toArray(c).filter(
47
+ const _ = t.useMemo(() => t.Children.toArray(c).filter(
48
48
  (e) => !t.isValidElement(e) || e.type !== B
49
- ), [c]), P = t.useMemo(() => t.Children.toArray(c).filter(
49
+ ), [c]), O = t.useMemo(() => t.Children.toArray(c).filter(
50
50
  (e) => t.isValidElement(e) && e.type === B
51
- ), [c]), { _id: R, contentId: g, id: C } = t.useMemo(() => {
51
+ ), [c]), { _id: P, contentId: g, id: C } = t.useMemo(() => {
52
52
  const e = r.id, s = `${e != null ? e : "accessibility"}-id`, G = `dialog-title-${s}`, H = `dialog-content-${s}`;
53
53
  return { _id: s, contentId: H, id: e || G };
54
- }, [r.id]), _ = t.useCallback(() => {
54
+ }, [r.id]), R = t.useCallback(() => {
55
55
  if (n.current)
56
56
  if (y && !a)
57
57
  n.current.focus();
@@ -65,12 +65,12 @@ const ce = V(), $ = t.forwardRef((j, z) => {
65
65
  Q(n.current, e);
66
66
  }
67
67
  }, [y, a]);
68
- t.useEffect(() => (_(), () => {
68
+ t.useEffect(() => (R(), () => {
69
69
  setTimeout(() => {
70
70
  var e;
71
71
  !n.current && l.current && Z && (document.contains(l.current) ? l.current.focus() : l.current.id && ((e = document.getElementById(l.current.id)) == null || e.focus()));
72
72
  });
73
- }), [_]);
73
+ }), [R]);
74
74
  const i = t.useCallback(
75
75
  (e) => {
76
76
  e.preventDefault(), Y(r.onClose, e, N(), void 0);
@@ -85,7 +85,7 @@ const ce = V(), $ = t.forwardRef((j, z) => {
85
85
  "div",
86
86
  {
87
87
  ref: n,
88
- [le]: R,
88
+ [le]: P,
89
89
  className: "k-dialog-wrapper" + (f ? " " + f : ""),
90
90
  onKeyDown: M,
91
91
  tabIndex: 0,
@@ -109,12 +109,12 @@ const ce = V(), $ = t.forwardRef((j, z) => {
109
109
  style: { width: D, height: h, minWidth: k }
110
110
  },
111
111
  m && /* @__PURE__ */ t.createElement(U, { closeIcon: F, onCloseButtonClick: i, id: C }, m),
112
- /* @__PURE__ */ t.createElement("div", { className: "k-window-content k-dialog-content", style: x, id: g }, O),
113
- P
112
+ /* @__PURE__ */ t.createElement("div", { className: "k-window-content k-dialog-content", style: x, id: g }, _),
113
+ O
114
114
  )
115
115
  )), [
116
116
  u,
117
- R,
117
+ P,
118
118
  f,
119
119
  M,
120
120
  T,
@@ -130,8 +130,8 @@ const ce = V(), $ = t.forwardRef((j, z) => {
130
130
  i,
131
131
  x,
132
132
  m,
133
+ _,
133
134
  O,
134
- P,
135
135
  A
136
136
  ]);
137
137
  return Z ? S !== null ? K.createPortal(L, S || document.body) : L : null;
@@ -8,11 +8,11 @@
8
8
  import * as n from "react";
9
9
  import t from "prop-types";
10
10
  import { classNames as c } from "@progress/kendo-react-common";
11
- const i = (s) => {
12
- const e = {
11
+ const i = (e) => {
12
+ const s = {
13
13
  layout: "stretched",
14
- ...s
15
- }, { layout: o, children: a } = e, r = c("k-actions", "k-actions-horizontal", "k-window-actions k-dialog-actions", {
14
+ ...e
15
+ }, { layout: o, children: a } = s, r = c("k-actions", "k-actions-horizontal", "k-window-actions k-dialog-actions", {
16
16
  [`k-actions-${o}`]: o
17
17
  });
18
18
  return /* @__PURE__ */ n.createElement("div", { className: r }, a);
package/Window.d.ts CHANGED
@@ -5,177 +5,40 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { default as PropTypes } from 'prop-types';
9
8
  import { WindowProps } from './WindowProps.js';
10
- import { Draggable, ZIndexContext } from '@progress/kendo-react-common';
11
- import { windowStage } from './StageEnum.js';
9
+ import { Draggable } from '@progress/kendo-react-common';
12
10
  import * as React from 'react';
13
- interface WindowState {
14
- stage: windowStage | string;
15
- isDragging: boolean;
16
- top: number;
17
- left: number;
18
- width: number;
19
- height: number | null;
20
- focused: boolean;
21
- zIndex: number;
22
- }
23
- /** @hidden */
24
- export declare class WindowWithoutContext extends React.Component<WindowProps, WindowState> {
25
- static displayName: string;
26
- /**
27
- * @hidden
28
- */
29
- static propTypes: {
30
- width: PropTypes.Requireable<number>;
31
- height: PropTypes.Requireable<number>;
32
- left: PropTypes.Requireable<number>;
33
- top: PropTypes.Requireable<number>;
34
- initialWidth: PropTypes.Requireable<number>;
35
- initialHeight: PropTypes.Requireable<number>;
36
- initialLeft: PropTypes.Requireable<number>;
37
- initialTop: PropTypes.Requireable<number>;
38
- minWidth: PropTypes.Requireable<number>;
39
- minHeight: PropTypes.Requireable<number>;
40
- resizable: PropTypes.Requireable<boolean>;
41
- draggable: PropTypes.Requireable<boolean>;
42
- title: PropTypes.Requireable<any>;
43
- shouldUpdateOnDrag: PropTypes.Requireable<boolean>;
44
- stage: PropTypes.Requireable<string>;
45
- className: PropTypes.Requireable<string>;
46
- id: PropTypes.Requireable<string>;
47
- style: PropTypes.Requireable<object>;
48
- overlayStyle: PropTypes.Requireable<object>;
49
- autoFocus: PropTypes.Requireable<boolean>;
50
- };
51
- /**
52
- * @hidden
53
- */
54
- static defaultProps: {
55
- minWidth: number;
56
- minHeight: number;
57
- resizable: boolean;
58
- draggable: boolean;
59
- modal: boolean;
60
- doubleClickStageChange: boolean;
61
- autoFocus: boolean;
62
- };
63
- /**
64
- * @hidden
65
- */
66
- static contextType: React.Context<import('@progress/kendo-react-common').ZIndexContextType>;
67
- /**
68
- * @hidden
69
- */
70
- context: React.ContextType<typeof ZIndexContext>;
71
- /**
72
- * **Deprecated.** Use `element` instead.
73
- */
74
- windowElement?: HTMLDivElement | null;
11
+ /**
12
+ * Represent the `ref` of the Window component.
13
+ */
14
+ export interface WindowHandle {
75
15
  /**
76
16
  * The Window element.
77
17
  */
78
18
  element?: HTMLDivElement | null;
79
19
  /**
80
- * @hidden
20
+ * **Deprecated.** Use `element` instead.
81
21
  */
82
- windowTitle?: any;
22
+ windowElement?: HTMLDivElement | null;
83
23
  /**
84
24
  * The draggable handle for the Window component.
85
25
  */
86
26
  draggable: Draggable | null;
87
- private windowCoordinatesState?;
88
- private offSetCoordinates?;
89
- private get _id();
90
- private titleId;
91
- private _blurTimeout?;
92
- private mounted;
93
- private activeElement;
94
- constructor(props: WindowProps);
95
- /**
96
- * @hidden
97
- */
98
- componentDidMount(): void;
99
- /**
100
- * @hidden
101
- */
102
- componentWillUnmount(): void;
103
27
  /**
104
- * @hidden
28
+ * The props of the WindowHandle component.
105
29
  */
106
- componentDidUpdate(prevProps: WindowProps): void;
107
- /**
108
- * @hidden
109
- */
110
- onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
111
- /**
112
- * @hidden
113
- */
114
- onPress: (data: any) => void;
115
- /**
116
- * @hidden
117
- */
118
- onDrag: (data: any) => void;
119
- /**
120
- * @hidden
121
- */
122
- onRelease: (data: any) => void;
123
- /**
124
- * @hidden
125
- */
126
- onFocus: () => void;
127
- /**
128
- * @hidden
129
- */
130
- onBlur: () => void;
131
- /**
132
- * @hidden
133
- */
134
- render(): React.JSX.Element | null;
135
- private get top();
136
- private get left();
137
- private get width();
138
- private get height();
139
- private get windowStage();
140
- private getInitialTop;
141
- private getInitialLeft;
142
- private getInitialWidth;
143
- private getInitialHeight;
144
- private handleMinimize;
145
- private handleFullscreen;
146
- private handleRestore;
147
- private handleCloseWindow;
148
- private handleDoubleClick;
149
- private handleResize;
150
- private dispatchMoveEvent;
151
- private handleBrowserWindowResize;
152
- private getActionBar;
153
- private getContent;
154
- private getCurrentZIndex;
155
- private getDocument;
156
- private getWindow;
157
- private generateTitleId;
30
+ props: Readonly<WindowProps>;
158
31
  }
159
32
  /**
160
- * Represents the PropsContext of the `Window` component.
161
- * Used for global configuration of all `Window` instances.
33
+ * Internal Window component implementation (functional component).
34
+ *
35
+ * @hidden
162
36
  */
163
- export declare const WindowPropsContext: React.Context<(p: WindowProps) => WindowProps>;
37
+ export declare const WindowWithoutContext: React.ForwardRefExoticComponent<WindowProps & React.RefAttributes<WindowHandle>>;
164
38
  /**
165
- * Represent the `ref` of the Window component.
39
+ * Context for Window props to enable child components to access parent Window props.
166
40
  */
167
- export interface WindowHandle extends Pick<WindowWithoutContext, keyof WindowWithoutContext> {
168
- /**
169
- * The Window element.
170
- */
171
- element?: HTMLDivElement | null;
172
- /**
173
- * **Deprecated.** Use `element` instead.
174
- */
175
- windowElement?: HTMLDivElement | null;
176
- }
177
- /** @hidden */
178
- export type Window = WindowHandle;
41
+ export declare const WindowPropsContext: React.Context<(p: WindowProps) => WindowProps>;
179
42
  /**
180
43
  * Represents the [KendoReact Window component](https://www.telerik.com/kendo-react-ui/components/dialogs/window).
181
44
  *
@@ -186,4 +49,3 @@ export type Window = WindowHandle;
186
49
  * Supported children components are: {@link WindowActionsBar}.
187
50
  */
188
51
  export declare const Window: React.ForwardRefExoticComponent<WindowProps & React.RefAttributes<any>>;
189
- export {};
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 U=require("react"),N=require("react-dom"),h=require("prop-types"),H=require("./WindowTitlebar.js"),o=require("@progress/kendo-react-common"),z=require("./WindowResizeHandlers.js"),k=require("./MiddleLayerOptimization.js"),s=require("./StageEnum.js"),A=require("./WindowActionsBar.js"),m=require("./constants.js"),B=require("./utils.js");function F(f){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const t in f)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(f,t);Object.defineProperty(i,t,e.get?e:{enumerable:!0,get:()=>f[t]})}}return i.default=f,Object.freeze(i)}const a=F(U),O=F(N),D=300,C=300,T=120,I=100,l=5,w=class w extends a.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=>{var d,u,S;if(this.props.modal&&o.keepFocusInContainer(t,this.element),t.target!==t.currentTarget)return;const e=this.props.minWidth||T,n=this.props.minHeight||I,r=t.metaKey||t.ctrlKey,c=(S=(u=this.height)!=null?u:(d=this.windowElement)==null?void 0:d.clientHeight)!=null?S:0;if(r&&this.props.resizable){switch(t.keyCode){case o.Keys.up:t.preventDefault(),n<=c-l&&this.setState({height:c-l});break;case o.Keys.down:t.preventDefault(),this.setState({height:c+l});break;case o.Keys.left:e<=this.width-l&&this.setState({width:this.width-l});break;case o.Keys.right:this.setState({width:this.width+l});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(p=>({top:p.top-l}));break;case o.Keys.down:this.setState(p=>({top:p.top+l}));break;case o.Keys.left:this.setState(p=>({left:p.left-l}));break;case o.Keys.right:this.setState(p=>({left:p.left+l}));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:B.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=()=>{var n,r;if(this.props.top!==void 0)return this.props.top;if(this.props.initialTop!==void 0)return this.props.initialTop;let t=C;if(this.props.height!==void 0?t=this.props.height:this.props.initialHeight!==void 0&&(t=this.props.initialHeight),this.props.appendTo&&t)return this.props.appendTo.offsetHeight/2-t/2;const e=this.getWindow();return e?e.innerHeight/2-((r=t!=null?t:(n=this.windowElement)==null?void 0:n.clientHeight)!=null?r:0)/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=D;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=D;return this.props.width!==void 0?t=this.props.width:this.props.initialWidth!==void 0&&(t=this.props.initialWidth),t},this.getInitialHeight=()=>{let t=C;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,r=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:r,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)=>{var W,M,v;const n=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,r=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,c=this.width,d=(v=(M=this.height)!=null?M:(W=this.windowElement)==null?void 0:W.clientHeight)!=null?v:0,u=this.props.minWidth||T,S=this.props.minHeight||I,p=this.top-r,L=this.left-n,b=n-this.left,y=r-this.top,g=Object.assign({},this.state,{isDragging:!e.end});e.direction.indexOf("n")>=0&&S-(d+p)<0&&(this.top>0&&(g.height=d+p),g.top=r),e.direction.indexOf("s")>=0&&S-y<0&&(g.height=y),e.direction.indexOf("w")>=0&&u-(c+L)<0&&(this.left>0&&(g.width=c+L),g.left=n),e.direction.indexOf("e")>=0&&u-b<0&&(g.width=b),this.setState(g),this.dispatchMoveEvent(this.props.onResize,t,!0,e.end)},this.dispatchMoveEvent=(t,e,n,r)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:n,end:r,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:m.DEFAULT_DIALOGS_ZINDEX:this.state.zIndex>(this.context?this.context+m.ZINDEX_DIALOGS_STEP:0)?this.state.zIndex:this.context+m.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:D,height:C,focused:!0,zIndex:m.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:B.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=a.Children.toArray(this.props.children),t=this.getContent(i),e=this.getActionBar(i),n=this.getCurrentZIndex(),r=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}),c=a.createElement(o.ZIndexContext.Provider,{value:n},a.createElement(a.Fragment,null,this.props.modal&&a.createElement("div",{className:"k-overlay",style:{zIndex:n,...this.props.overlayStyle}}),a.createElement("div",{id:this.props.id,[m.DATA_DIALOGS_ID]:this._id,tabIndex:0,role:"dialog","aria-labelledby":this.titleId,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,ref:d=>{this.windowElement=d,this.element=d},className:r,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:n,...this.props.style}},a.createElement(k.MiddleLayerOptimization,{shouldUpdateOnDrag:this.props.shouldUpdateOnDrag||!1,isDragging:this.state.isDragging},a.createElement(o.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,autoScroll:!1,ref:d=>{this.draggable=d}},a.createElement(H.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?a.createElement(a.Fragment,null,a.createElement("div",{className:"k-window-content"},t),e):null,this.windowStage===s.windowStage.DEFAULT&&this.props.resizable?a.createElement(z.ResizeHandlers,{onResize:this.handleResize}):null))));return o.canUseDOM?this.props.appendTo!==null?O.createPortal(c,this.props.appendTo||document.body):c: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===A.WindowActionsBar)}getContent(i){return i.filter(t=>t&&t.type!==A.WindowActionsBar)}generateTitleId(){return"window-title-"+this._id}};w.displayName="Window",w.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},w.defaultProps={minWidth:T,minHeight:I,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},w.contextType=o.ZIndexContext;let E=w;const R=o.createPropsContext(),x=o.withIdHOC(o.withPropsContext(R,E));x.displayName="KendoReactWindow";exports.Window=x;exports.WindowPropsContext=R;exports.WindowWithoutContext=E;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const dt=require("react"),lt=require("react-dom"),ut=require("prop-types"),ft=require("./WindowTitlebar.js"),a=require("@progress/kendo-react-common"),gt=require("./WindowResizeHandlers.js"),ht=require("./MiddleLayerOptimization.js"),o=require("./StageEnum.js"),Ke=require("./WindowActionsBar.js"),p=require("./constants.js"),Pe=require("./utils.js");function Ee(e){const S=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const A in e)if(A!=="default"){const k=Object.getOwnPropertyDescriptor(e,A);Object.defineProperty(S,A,k.get?k:{enumerable:!0,get:()=>e[A]})}}return S.default=e,Object.freeze(S)}const T=Ee(dt),st=Ee(lt),i=Ee(ut),{useState:H,useEffect:U,useCallback:u,useMemo:q,useRef:F,useImperativeHandle:wt,useContext:Et,forwardRef:Tt}=T,ee=300,te=300,se=120,we=100,b=5,x={minWidth:se,minHeight:we,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},Te=Tt((e,S)=>{var He;const{minWidth:A=x.minWidth,minHeight:k=x.minHeight,resizable:ue=x.resizable,draggable:Se=x.draggable,modal:fe=x.modal,doubleClickStageChange:je=x.doubleClickStageChange,autoFocus:Xe=x.autoFocus}=e,[Ge,j]=H(e.stage||o.windowStage.DEFAULT),[X,ne]=H(!1),[ie,I]=H(0),[oe,y]=H(0),[ae,N]=H(ee),[ce,W]=H(te),[Ve,ge]=H(!0),[he,De]=H(p.DEFAULT_DIALOGS_ZINDEX),r=(He=e.stage)!=null?He:Ge,B=Et(a.ZIndexContext),R=F(null),Ce=F(null),h=F({leftBeforeAction:0,topBeforeAction:0,widthBeforeAction:ee,heightBeforeAction:te}),O=F({x:0,y:0}),z=F(void 0),G=F(a.canUseDOM?document.activeElement:null),Le=F("window-title-"+(e.id?e.id+"-accessibility-id":"")),_=F({left:0,top:0,width:ee,height:te,internalLeft:oe,internalTop:ie,internalWidth:ae,internalHeight:ce,stage:r,draggable:Se,props:e}),M=u(()=>{const t=a.canUseDOM?document:null;return e.appendTo?e.appendTo.ownerDocument:t},[e.appendTo]),w=u(()=>{const t=M();return t==null?void 0:t.defaultView},[M]),Z=q(()=>{var t;return r!==o.windowStage.FULLSCREEN?Math.max((t=e.top)!=null?t:ie,0):0},[r,e.top,ie]),K=q(()=>{var t;return r!==o.windowStage.FULLSCREEN?Math.max((t=e.left)!=null?t:oe,0):0},[r,e.left,oe]),D=q(()=>{var n;const t=(n=e.width)!=null?n:ae;if(r===o.windowStage.FULLSCREEN){if(e.appendTo)return e.appendTo.offsetWidth;const c=w();return c?c.innerWidth:0}return t},[r,e.width,e.appendTo,ae,w]),C=q(()=>{const t=e.height===void 0?ce:e.height;if(r===o.windowStage.FULLSCREEN){if(e.appendTo)return e.appendTo.offsetHeight;const n=w();return n?n.innerHeight:0}else if(r===o.windowStage.MINIMIZED)return 0;return t},[r,e.height,e.appendTo,ce,w]),re=q(()=>e.id?e.id+"-accessibility-id":void 0,[e.id]);U(()=>{_.current={left:K,top:Z,width:D,height:C,internalLeft:oe,internalTop:ie,internalWidth:ae,internalHeight:ce,stage:r,draggable:Se,props:e}});const P=q(()=>{if(B===void 0)return B!=null?B:p.DEFAULT_DIALOGS_ZINDEX;const t=B?B+p.ZINDEX_DIALOGS_STEP:0;return he>t?he:B+p.ZINDEX_DIALOGS_STEP},[he,B]),be=u(()=>{var c,l;if(e.top!==void 0)return e.top;if(e.initialTop!==void 0)return e.initialTop;let t=te;if(e.height!==void 0?t=e.height:e.initialHeight!==void 0&&(t=e.initialHeight),e.appendTo&&t)return e.appendTo.offsetHeight/2-t/2;const n=w();return n?n.innerHeight/2-((l=t!=null?t:(c=R.current)==null?void 0:c.clientHeight)!=null?l:0)/2:0},[e.top,e.initialTop,e.height,e.initialHeight,e.appendTo,w]),Ie=u(()=>{if(e.left!==void 0)return e.left;if(e.initialLeft!==void 0)return e.initialLeft;let t=ee;if(e.width!==void 0?t=e.width:e.initialWidth!==void 0&&(t=e.initialWidth),e.appendTo)return e.appendTo.offsetWidth/2-t/2;const n=w();return n?n.innerWidth/2-t/2:0},[e.left,e.initialLeft,e.width,e.initialWidth,e.appendTo,w]),ye=u(()=>{let t=ee;return e.width!==void 0?t=e.width:e.initialWidth!==void 0&&(t=e.initialWidth),t},[e.width,e.initialWidth]),We=u(()=>{let t=te;return e.height!==void 0?t=e.height:e.initialHeight!==void 0&&(t=e.initialHeight),t},[e.height,e.initialHeight]),Ye=u(t=>t.filter(n=>(n==null?void 0:n.type)===Ke.WindowActionsBar),[]),$e=u(t=>t.filter(n=>n&&n.type!==Ke.WindowActionsBar),[]),E=u(()=>typeof S=="object"&&S!==null&&"current"in S?S.current:null,[S]),v=u((t,n,c,l,d,f)=>{var Y,$,J;if(!t)return;const{internalLeft:m,internalTop:s,internalWidth:L,internalHeight:le}=_.current;t({nativeEvent:n.nativeEvent?n.nativeEvent:n.originalEvent,drag:c,end:l,target:E(),left:(Y=d==null?void 0:d.left)!=null?Y:m,top:($=d==null?void 0:d.top)!=null?$:s,width:(J=f==null?void 0:f.width)!=null?J:L,height:(f==null?void 0:f.height)===void 0?le:f==null?void 0:f.height})},[E]),Je=u(t=>{var f,m;if(fe&&a.keepFocusInContainer(t,R.current),t.target!==t.currentTarget)return;const n=A||se,c=k||we,l=t.metaKey||t.ctrlKey,d=(m=C!=null?C:(f=R.current)==null?void 0:f.clientHeight)!=null?m:0;if(l&&ue){switch(t.keyCode){case a.Keys.up:t.preventDefault(),c<=d-b&&W(d-b);break;case a.Keys.down:t.preventDefault(),W(d+b);break;case a.Keys.left:n<=D-b&&N(D-b);break;case a.Keys.right:N(D+b);break;default:return}v(e.onResize,t,!1,void 0);return}if(t.altKey){switch(t.keyCode){case a.Keys.up:r===o.windowStage.MINIMIZED?(V(t),a.dispatchEvent(e.onStageChange,t,E(),{state:o.windowStage.DEFAULT})):r===o.windowStage.DEFAULT&&(de(t),a.dispatchEvent(e.onStageChange,t,E(),{state:o.windowStage.FULLSCREEN}));break;case a.Keys.down:r===o.windowStage.FULLSCREEN?(V(t),a.dispatchEvent(e.onStageChange,t,E(),{state:o.windowStage.DEFAULT})):r===o.windowStage.DEFAULT&&(ve(t),a.dispatchEvent(e.onStageChange,t,E(),{state:o.windowStage.MINIMIZED}));break}return}if(!t.ctrlKey)switch(t.keyCode){case a.Keys.esc:e.onClose&&Ae(t);return;case a.Keys.up:I(s=>s-b);break;case a.Keys.down:I(s=>s+b);break;case a.Keys.left:y(s=>s-b);break;case a.Keys.right:y(s=>s+b);break;default:return}v(e.onMove,t,!1,void 0)},[fe,A,k,ue,e.onResize,e.onStageChange,e.onClose,e.onMove,C,D,r,v,E]),Qe=u(t=>{const n=t.event,{left:c,top:l}=_.current;h.current.differenceLeft=n.pageX-c,h.current.differenceTop=n.pageY-l},[]),pe=u(t=>{const n=t.event;n.originalEvent.preventDefault();const{stage:c,draggable:l,props:d,width:f,height:m}=_.current;if(c!==o.windowStage.FULLSCREEN&&l){const s=Math.max(n.pageY-(h.current.differenceTop||0),0),L=n.pageX-(h.current.differenceLeft||0);I(s),y(L),ne(!0),d.onMove&&v(d.onMove,n,!0,!1,{left:L,top:s},{width:f,height:m})}},[v]),et=u(t=>{const n=t.event,{stage:c,draggable:l,props:d,left:f,top:m,width:s,height:L}=_.current;c!==o.windowStage.FULLSCREEN&&l&&d.onMove&&v(d.onMove,n,!0,!0,{left:f,top:m},{width:s,height:L}),ne(!1)},[v]),tt=u(()=>{z.current?(clearTimeout(z.current),z.current=void 0):(ge(!0),De(Pe.getMaxZIndex(P,M(),re)))},[P,M,re]),nt=u(()=>{clearTimeout(z.current);const t=w();t&&(z.current=t.setTimeout(()=>{ge(!1),z.current=void 0}))},[w]),ve=u(t=>{t.preventDefault(),h.current.leftBeforeAction=K,h.current.topBeforeAction=Z,h.current.widthBeforeAction=D,h.current.heightBeforeAction=C,j(o.windowStage.MINIMIZED),W(0),a.dispatchEvent(e.onStageChange,t,E(),{state:o.windowStage.MINIMIZED})},[K,Z,D,C,e.onStageChange,E]),de=u(t=>{t.preventDefault(),h.current.leftBeforeAction=K,h.current.topBeforeAction=Z,h.current.widthBeforeAction=D,h.current.heightBeforeAction=C;const n=w(),c=n?n.innerWidth:0,l=n?n.innerHeight:0;y(0),I(0),N(e.appendTo?e.appendTo.offsetWidth:c),W(e.appendTo?e.appendTo.offsetHeight:l),j(o.windowStage.FULLSCREEN),a.dispatchEvent(e.onStageChange,t,E(),{state:o.windowStage.FULLSCREEN})},[K,Z,D,C,e.appendTo,e.onStageChange,w,E]),V=u(t=>{t.preventDefault(),r===o.windowStage.FULLSCREEN?(j(o.windowStage.DEFAULT),y(h.current.leftBeforeAction),I(h.current.topBeforeAction),N(h.current.widthBeforeAction),W(h.current.heightBeforeAction)):r===o.windowStage.MINIMIZED&&(j(o.windowStage.DEFAULT),W(h.current.heightBeforeAction)),a.dispatchEvent(e.onStageChange,t,E(),{state:o.windowStage.DEFAULT})},[r,e.onStageChange,E]),Ae=u(t=>{t.preventDefault(),a.dispatchEvent(e.onClose,t,E(),{state:void 0})},[e.onClose,E]),it=u(t=>{r===o.windowStage.FULLSCREEN||r===o.windowStage.MINIMIZED?V(t):de(t)},[r,V,de]),ot=u((t,n)=>{var xe,ke,Oe,ze,_e,Ze;const{props:c,width:l,height:d,top:f,left:m}=_.current,s=c.appendTo?t.pageX-O.current.x:t.pageX,L=c.appendTo?t.pageY-O.current.y:t.pageY,le=(ke=d!=null?d:(xe=R.current)==null?void 0:xe.clientHeight)!=null?ke:0,Y=A||se,$=k||we,J=f-L,Fe=m-s,Ne=s-m,Ue=L-f;let Q=!1;const g={isDragging:!n.end};n.direction.indexOf("n")>=0&&$-(le+J)<0&&(f>0&&(g.height=le+J),g.top=L,Q=!0),n.direction.indexOf("s")>=0&&$-Ue<0&&(g.height=Ue,Q=!0),n.direction.indexOf("w")>=0&&Y-(l+Fe)<0&&(m>0&&(g.width=l+Fe),g.left=s,Q=!0),n.direction.indexOf("e")>=0&&Y-Ne<0&&(g.width=Ne,Q=!0),Q&&(g.height!==void 0&&W(g.height),g.top!==void 0&&I(g.top),g.width!==void 0&&N(g.width),g.left!==void 0&&y(g.left),g.isDragging!==void 0&&ne(g.isDragging)),v(c.onResize,t,!0,n.end,{left:(Oe=g.left)!=null?Oe:m,top:(ze=g.top)!=null?ze:f},{width:(_e=g.width)!=null?_e:l,height:(Ze=g.height)!=null?Ze:d})},[v]),Be=u(()=>{if(r===o.windowStage.FULLSCREEN){const t=w(),n=t?t.innerWidth:0,c=t?t.innerHeight:0;N(e.appendTo?e.appendTo.offsetWidth:n),W(e.appendTo?e.appendTo.offsetHeight:c)}},[r,e.appendTo,w]);U(()=>{const t=R.current;t&&Xe&&t.focus({preventScroll:!0});const n=w();n&&n.addEventListener("resize",Be),j(e.stage||o.windowStage.DEFAULT),ne(!1),I(be()),y(Ie()),N(ye()),W(We()),ge(!0),De(Pe.getMaxZIndex(P,M(),re)),h.current={leftBeforeAction:Ie(),topBeforeAction:be(),widthBeforeAction:ye(),heightBeforeAction:We()};const c=M();if(e.appendTo&&c){const l=e.appendTo.getBoundingClientRect(),d=c.body.getBoundingClientRect();O.current.x=l.left-d.left,O.current.y=l.top-d.top}return()=>{var d;const l=w();l&&l.removeEventListener("resize",Be),G.current&&a.canUseDOM&&(document.contains(G.current)?G.current.focus({preventScroll:!0}):G.current.id&&((d=document.getElementById(G.current.id))==null||d.focus({preventScroll:!0})))}},[]),U(()=>{e.left!==void 0&&!X&&y(e.left)},[e.left,X]),U(()=>{e.top!==void 0&&!X&&I(e.top)},[e.top,X]),U(()=>{e.initialLeft!==void 0&&y(e.initialLeft)},[e.initialLeft]),U(()=>{e.initialTop!==void 0&&I(e.initialTop)},[e.initialTop]),U(()=>{const t=M();if(e.appendTo&&t){const n=e.appendTo.getBoundingClientRect(),c=t.body.getBoundingClientRect();O.current.x=n.left-c.left,O.current.y=n.top-c.top}},[e.appendTo,M]),wt(S,()=>({get element(){return R.current},get windowElement(){return R.current},get draggable(){return Ce.current},props:e}),[e]);const Re=T.Children.toArray(e.children),at=$e(Re),ct=Ye(Re),rt=a.classNames("k-window",e.className,{[`k-window-${e.themeColor}`]:e.themeColor,"k-window-minimized":r==="MINIMIZED","k-focus":Ve}),Me=T.createElement(a.ZIndexContext.Provider,{value:P},T.createElement(T.Fragment,null,fe&&T.createElement("div",{className:"k-overlay",style:{zIndex:P,...e.overlayStyle}}),T.createElement("div",{id:e.id,[p.DATA_DIALOGS_ID]:re,tabIndex:0,role:"dialog","aria-labelledby":Le.current,onFocus:tt,onBlur:nt,onKeyDown:Je,ref:R,className:rt,style:{top:Z,left:K,width:D,height:C||"",zIndex:P,...e.style}},T.createElement(ht.MiddleLayerOptimization,{shouldUpdateOnDrag:e.shouldUpdateOnDrag||!1,isDragging:X},T.createElement(a.Draggable,{onPress:Qe,onDrag:pe,onRelease:et,autoScroll:!1,ref:Ce},T.createElement(ft.WindowTitleBar,{stage:r,onDoubleClick:je?it:void 0,onMinimizeButtonClick:ve,onFullScreenButtonClick:de,onRestoreButtonClick:V,onCloseButtonClick:Ae,closeButton:e.closeButton,minimizeButton:e.minimizeButton,maximizeButton:e.maximizeButton,restoreButton:e.restoreButton,id:Le.current},e.title)),r===o.windowStage.MINIMIZED?null:T.createElement(T.Fragment,null,T.createElement("div",{className:"k-window-content"},at),ct),r===o.windowStage.DEFAULT&&ue?T.createElement(gt.ResizeHandlers,{onResize:ot}):null))));return a.canUseDOM?e.appendTo===null?Me:st.createPortal(Me,e.appendTo||document.body):null});Te.displayName="Window";const qe=a.createPropsContext(),me=a.withIdHOC(a.withPropsContext(qe,Te));me.displayName="KendoReactWindow";const mt={autoFocus:i.bool,title:i.any,className:i.string,closeButton:i.func,minimizeButton:i.func,maximizeButton:i.func,restoreButton:i.func,modal:i.bool,overlayStyle:i.object,width:i.number,height:i.number,minWidth:i.number,minHeight:i.number,left:i.number,top:i.number,initialLeft:i.number,initialTop:i.number,initialWidth:i.number,initialHeight:i.number,resizable:i.bool,draggable:i.bool,doubleClickStageChange:i.bool,stage:i.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),onClose:i.func,onMove:i.func,onResize:i.func,onStageChange:i.func,children:i.node,id:i.string,dir:i.string,style:i.object,appendTo:i.any,themeColor:i.oneOf(["primary","dark","light"]),shouldUpdateOnDrag:i.bool};me.propTypes=mt;exports.Window=me;exports.WindowPropsContext=qe;exports.WindowWithoutContext=Te;