@progress/kendo-react-dialogs 10.2.0-develop.8 → 10.2.0
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.js +1 -1
- package/Dialog.mjs +33 -30
- package/Window.js +1 -1
- package/Window.mjs +39 -36
- package/dist/cdn/js/kendo-react-dialogs.js +1 -1
- package/package.json +4 -4
package/Dialog.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 A=require("react"),F=require("react-dom"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react"),F=require("react-dom"),o=require("prop-types"),_=require("./DialogTitleBar.js"),u=require("./DialogActionsBar.js"),s=require("@progress/kendo-react-common"),N=require("./utils.js"),l=require("./constants.js");function m(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const c=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,c.get?c:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const n=m(A),k=m(F),i=class i extends n.Component{constructor(t){super(t),this.context=0,this.titleId=this.generateTitleId(),this.contentId=this.generateContentId(),this.activeElement=null,this.onCloseDialog=e=>{e.preventDefault(),s.dispatchEvent(this.props.onClose,e,this,void 0)},this.onKeyDown=e=>{e.keyCode===s.Keys.esc&&this.props.onClose&&(e.preventDefault(),this.onCloseDialog(e)),s.keepFocusInContainer(e,this.element)},this.getCurrentZIndex=()=>!this.state||this.context===void 0?this.context?this.context:l.DEFAULT_DIALOGS_ZINDEX:this.state.zIndex>(this.context?this.context+l.ZINDEX_DIALOGS_STEP:0)?this.state.zIndex:this.context+l.ZINDEX_DIALOGS_STEP,this.getDocument=()=>{const e=s.canUseDOM?document:null;return this.props.appendTo?this.props.appendTo.ownerDocument:e},s.canUseDOM&&(this.activeElement=s.getActiveElement(document))}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){if(this.element){if(this.props.autoFocus&&!this.props.autoFocusedElement)this.element.focus();else if(this.props.autoFocus&&this.props.autoFocusedElement)this.element.focus();else if(!this.props.autoFocus&&this.props.autoFocusedElement){const t=this.element.querySelector(this.props.autoFocusedElement);t&&t.focus()}else{const t=[...s.FOCUSABLE_ELEMENTS].map(e=>e+":not(.k-dialog-titlebar *)");s.focusFirstFocusableChild(this.element,t)}this.setState({zIndex:N.getMaxZIndex(this.getCurrentZIndex(),this.getDocument(),this._id)})}}componentWillUnmount(){setTimeout(()=>{var t;!this.element&&this.activeElement&&s.canUseDOM&&(document.contains(this.activeElement)?this.activeElement.focus():this.activeElement.id&&((t=document.getElementById(this.activeElement.id))==null||t.focus()))})}render(){const t=this.props.id!==void 0?this.props.id:this.titleId,{title:e,width:c,height:f,children:D,minWidth:I,dir:E,style:b,contentStyle:C,modal:x=!0}=this.props,d=n.Children.toArray(D),T=this.getContent(d),v=this.getActionBar(d),O=e?{"aria-labelledby":t}:null,S=this.props.closeIcon!==void 0?this.props.closeIcon:!0,p=this.getCurrentZIndex(),h=n.createElement(s.ZIndexContext.Provider,{value:p},n.createElement("div",{[l.DATA_DIALOGS_ID]:this._id,className:"k-dialog-wrapper"+(this.props.className?" "+this.props.className:""),onKeyDown:this.onKeyDown,tabIndex:0,dir:E,style:{zIndex:p,...b},ref:w=>{this.element=w}},x&&n.createElement("div",{className:"k-overlay",style:this.props.overlayStyle}),n.createElement("div",{...O,className:s.classNames("k-window k-dialog",{[`k-window-${this.props.themeColor}`]:this.props.themeColor}),role:"dialog","aria-labelledby":t,"aria-modal":!0,"aria-describedby":this.contentId,style:{width:c,height:f,minWidth:I}},this.props.title&&n.createElement(_.DialogTitleBar,{closeIcon:S,onCloseButtonClick:this.onCloseDialog,id:t},e),n.createElement("div",{className:"k-window-content k-dialog-content",style:C,id:this.contentId},T),v)));return s.canUseDOM?this.props.appendTo!==null?k.createPortal(h,this.props.appendTo||document.body):h:null}getActionBar(t){return t.filter(e=>e&&e.type===u.DialogActionsBar)}getContent(t){return t.filter(e=>e&&e.type!==u.DialogActionsBar)}generateTitleId(){return"dialog-title-"+this._id}generateContentId(){return"dialog-content-"+this._id}};i.displayName="Dialog",i.propTypes={title:o.any,id:o.string,dir:o.string,style:o.object,closeIcon:o.bool,width:o.oneOfType([o.number,o.string]),height:o.oneOfType([o.number,o.string]),minWidth:o.oneOfType([o.number,o.string]),autoFocus:o.bool},i.defaultProps={autoFocus:!1},i.contextType=s.ZIndexContext;let a=i;const g=s.createPropsContext(),y=s.withIdHOC(s.withPropsContext(g,a));y.displayName="KendoReactDialog";exports.Dialog=y;exports.DialogPropsContext=g;
|
package/Dialog.mjs
CHANGED
|
@@ -6,20 +6,23 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as o from "react";
|
|
9
|
-
import * as
|
|
9
|
+
import * as w from "react-dom";
|
|
10
10
|
import s from "prop-types";
|
|
11
|
-
import { DialogTitleBar as
|
|
12
|
-
import { DialogActionsBar as
|
|
13
|
-
import { dispatchEvent as
|
|
11
|
+
import { DialogTitleBar as F } from "./DialogTitleBar.mjs";
|
|
12
|
+
import { DialogActionsBar as p } from "./DialogActionsBar.mjs";
|
|
13
|
+
import { dispatchEvent as A, Keys as N, keepFocusInContainer as k, canUseDOM as n, getActiveElement as S, ZIndexContext as d, FOCUSABLE_ELEMENTS as O, focusFirstFocusableChild as P, classNames as Z, createPropsContext as _, withIdHOC as B, withPropsContext as L } from "@progress/kendo-react-common";
|
|
14
14
|
import { getMaxZIndex as K } from "./utils.mjs";
|
|
15
|
-
import { DEFAULT_DIALOGS_ZINDEX as M, ZINDEX_DIALOGS_STEP as
|
|
15
|
+
import { DEFAULT_DIALOGS_ZINDEX as M, ZINDEX_DIALOGS_STEP as h, DATA_DIALOGS_ID as z } from "./constants.mjs";
|
|
16
16
|
const i = class i extends o.Component {
|
|
17
17
|
constructor(e) {
|
|
18
18
|
super(e), this.context = 0, this.titleId = this.generateTitleId(), this.contentId = this.generateContentId(), this.activeElement = null, this.onCloseDialog = (t) => {
|
|
19
|
-
t.preventDefault(),
|
|
19
|
+
t.preventDefault(), A(this.props.onClose, t, this, void 0);
|
|
20
20
|
}, this.onKeyDown = (t) => {
|
|
21
|
-
t.keyCode ===
|
|
22
|
-
}, this.getCurrentZIndex = () => !this.state || this.context === void 0 ? this.context ? this.context : M : this.state.zIndex > (this.context ? this.context +
|
|
21
|
+
t.keyCode === N.esc && this.props.onClose && (t.preventDefault(), this.onCloseDialog(t)), k(t, this.element);
|
|
22
|
+
}, this.getCurrentZIndex = () => !this.state || this.context === void 0 ? this.context ? this.context : M : this.state.zIndex > (this.context ? this.context + h : 0) ? this.state.zIndex : this.context + h, this.getDocument = () => {
|
|
23
|
+
const t = n ? document : null;
|
|
24
|
+
return this.props.appendTo ? this.props.appendTo.ownerDocument : t;
|
|
25
|
+
}, n && (this.activeElement = S(document));
|
|
23
26
|
}
|
|
24
27
|
get _id() {
|
|
25
28
|
return this.props.id + "-accessibility-id";
|
|
@@ -39,10 +42,10 @@ const i = class i extends o.Component {
|
|
|
39
42
|
);
|
|
40
43
|
e && e.focus();
|
|
41
44
|
} else {
|
|
42
|
-
const e = [...
|
|
45
|
+
const e = [...O].map(
|
|
43
46
|
(t) => t + ":not(.k-dialog-titlebar *)"
|
|
44
47
|
);
|
|
45
|
-
|
|
48
|
+
P(this.element, e);
|
|
46
49
|
}
|
|
47
50
|
this.setState({
|
|
48
51
|
zIndex: K(this.getCurrentZIndex(), this.getDocument(), this._id)
|
|
@@ -55,16 +58,16 @@ const i = class i extends o.Component {
|
|
|
55
58
|
componentWillUnmount() {
|
|
56
59
|
setTimeout(() => {
|
|
57
60
|
var e;
|
|
58
|
-
!this.element && this.activeElement &&
|
|
61
|
+
!this.element && this.activeElement && n && (document.contains(this.activeElement) ? this.activeElement.focus() : this.activeElement.id && ((e = document.getElementById(this.activeElement.id)) == null || e.focus()));
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* @hidden
|
|
63
66
|
*/
|
|
64
67
|
render() {
|
|
65
|
-
const e = this.props.id !== void 0 ? this.props.id : this.titleId, { title: t, width:
|
|
68
|
+
const e = this.props.id !== void 0 ? this.props.id : this.titleId, { title: t, width: m, height: u, children: f, minWidth: g, dir: y, style: I, contentStyle: E, modal: D = !0 } = this.props, l = o.Children.toArray(f), C = this.getContent(l), x = this.getActionBar(l), v = t ? {
|
|
66
69
|
"aria-labelledby": e
|
|
67
|
-
} : null,
|
|
70
|
+
} : null, T = this.props.closeIcon !== void 0 ? this.props.closeIcon : !0, a = this.getCurrentZIndex(), c = /* @__PURE__ */ o.createElement(d.Provider, { value: a }, /* @__PURE__ */ o.createElement(
|
|
68
71
|
"div",
|
|
69
72
|
{
|
|
70
73
|
[z]: this._id,
|
|
@@ -73,39 +76,39 @@ const i = class i extends o.Component {
|
|
|
73
76
|
tabIndex: 0,
|
|
74
77
|
dir: y,
|
|
75
78
|
style: {
|
|
76
|
-
zIndex:
|
|
77
|
-
...
|
|
79
|
+
zIndex: a,
|
|
80
|
+
...I
|
|
78
81
|
},
|
|
79
|
-
ref: (
|
|
80
|
-
this.element =
|
|
82
|
+
ref: (b) => {
|
|
83
|
+
this.element = b;
|
|
81
84
|
}
|
|
82
85
|
},
|
|
83
|
-
|
|
86
|
+
D && /* @__PURE__ */ o.createElement("div", { className: "k-overlay", style: this.props.overlayStyle }),
|
|
84
87
|
/* @__PURE__ */ o.createElement(
|
|
85
88
|
"div",
|
|
86
89
|
{
|
|
87
|
-
...
|
|
88
|
-
className:
|
|
90
|
+
...v,
|
|
91
|
+
className: Z("k-window k-dialog", {
|
|
89
92
|
[`k-window-${this.props.themeColor}`]: this.props.themeColor
|
|
90
93
|
}),
|
|
91
94
|
role: "dialog",
|
|
92
95
|
"aria-labelledby": e,
|
|
93
96
|
"aria-modal": !0,
|
|
94
97
|
"aria-describedby": this.contentId,
|
|
95
|
-
style: { width:
|
|
98
|
+
style: { width: m, height: u, minWidth: g }
|
|
96
99
|
},
|
|
97
|
-
this.props.title && /* @__PURE__ */ o.createElement(
|
|
98
|
-
/* @__PURE__ */ o.createElement("div", { className: "k-window-content k-dialog-content", style:
|
|
99
|
-
|
|
100
|
+
this.props.title && /* @__PURE__ */ o.createElement(F, { closeIcon: T, onCloseButtonClick: this.onCloseDialog, id: e }, t),
|
|
101
|
+
/* @__PURE__ */ o.createElement("div", { className: "k-window-content k-dialog-content", style: E, id: this.contentId }, C),
|
|
102
|
+
x
|
|
100
103
|
)
|
|
101
104
|
));
|
|
102
|
-
return
|
|
105
|
+
return n ? this.props.appendTo !== null ? w.createPortal(c, this.props.appendTo || document.body) : c : null;
|
|
103
106
|
}
|
|
104
107
|
getActionBar(e) {
|
|
105
|
-
return e.filter((t) => t && t.type ===
|
|
108
|
+
return e.filter((t) => t && t.type === p);
|
|
106
109
|
}
|
|
107
110
|
getContent(e) {
|
|
108
|
-
return e.filter((t) => t && t.type !==
|
|
111
|
+
return e.filter((t) => t && t.type !== p);
|
|
109
112
|
}
|
|
110
113
|
generateTitleId() {
|
|
111
114
|
return "dialog-title-" + this._id;
|
|
@@ -126,12 +129,12 @@ i.displayName = "Dialog", i.propTypes = {
|
|
|
126
129
|
autoFocus: s.bool
|
|
127
130
|
}, i.defaultProps = {
|
|
128
131
|
autoFocus: !1
|
|
129
|
-
}, i.contextType =
|
|
130
|
-
let
|
|
132
|
+
}, i.contextType = d;
|
|
133
|
+
let r = i;
|
|
131
134
|
const U = _(), G = B(
|
|
132
135
|
L(
|
|
133
136
|
U,
|
|
134
|
-
|
|
137
|
+
r
|
|
135
138
|
)
|
|
136
139
|
);
|
|
137
140
|
G.displayName = "KendoReactDialog";
|
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"),N=require("./WindowResizeHandlers.js"),U=require("./MiddleLayerOptimization.js"),s=require("./StageEnum.js"),W=require("./WindowActionsBar.js"),f=require("./constants.js"),v=require("./utils.js");function M(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=M(F),z=M(R),S=300,m=300,E=120,C=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||C;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:v.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,D=this.props.minWidth||E,I=this.props.minHeight||C,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&&D-(a+b)<0&&(this.left>0&&(c.width=a+b),c.left=n),e.direction.indexOf("e")>=0&&D-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=()=>this.props.appendTo?this.props.appendTo.ownerDocument:document,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},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:v.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&&document&&(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(U.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(N.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:C,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,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;
|
package/Window.mjs
CHANGED
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as h from "react";
|
|
9
|
-
import * as
|
|
9
|
+
import * as B from "react-dom";
|
|
10
10
|
import n from "prop-types";
|
|
11
|
-
import { WindowTitleBar as
|
|
12
|
-
import { keepFocusInContainer as
|
|
11
|
+
import { WindowTitleBar as R } from "./WindowTitlebar.mjs";
|
|
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
|
|
19
|
-
const
|
|
16
|
+
import { WindowActionsBar as v } from "./WindowActionsBar.mjs";
|
|
17
|
+
import { DEFAULT_DIALOGS_ZINDEX as F, ZINDEX_DIALOGS_STEP as y, DATA_DIALOGS_ID as O } from "./constants.mjs";
|
|
18
|
+
import { getMaxZIndex as A } from "./utils.mjs";
|
|
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) => {
|
|
22
|
-
if (this.props.modal &&
|
|
22
|
+
if (this.props.modal && x(t, this.element), t.target !== t.currentTarget)
|
|
23
23
|
return;
|
|
24
|
-
const e = this.props.minWidth ||
|
|
24
|
+
const e = this.props.minWidth || S, o = this.props.minHeight || E;
|
|
25
25
|
if ((t.metaKey || t.ctrlKey) && this.props.resizable) {
|
|
26
26
|
switch (t.keyCode) {
|
|
27
27
|
case a.up:
|
|
@@ -92,7 +92,7 @@ const u = 300, w = 300, m = 120, S = 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: A(this.getCurrentZIndex(), this.getDocument(), this._id)
|
|
96
96
|
});
|
|
97
97
|
}, this.onBlur = () => {
|
|
98
98
|
clearTimeout(this._blurTimeout);
|
|
@@ -105,7 +105,7 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
105
105
|
return this.props.top;
|
|
106
106
|
if (this.props.initialTop !== void 0)
|
|
107
107
|
return this.props.initialTop;
|
|
108
|
-
let t =
|
|
108
|
+
let t = m;
|
|
109
109
|
if (this.props.height !== void 0 ? t = this.props.height : this.props.initialHeight !== void 0 && (t = this.props.initialHeight), this.props.appendTo)
|
|
110
110
|
return this.props.appendTo.offsetHeight / 2 - t / 2;
|
|
111
111
|
const e = this.getWindow();
|
|
@@ -115,16 +115,16 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
115
115
|
return this.props.left;
|
|
116
116
|
if (this.props.initialLeft !== void 0)
|
|
117
117
|
return this.props.initialLeft;
|
|
118
|
-
let t =
|
|
118
|
+
let t = w;
|
|
119
119
|
if (this.props.width !== void 0 ? t = this.props.width : this.props.initialWidth !== void 0 && (t = this.props.initialWidth), this.props.appendTo)
|
|
120
120
|
return this.props.appendTo.offsetWidth / 2 - t / 2;
|
|
121
121
|
const e = this.getWindow();
|
|
122
122
|
return e ? e.innerWidth / 2 - t / 2 : 0;
|
|
123
123
|
}, this.getInitialWidth = () => {
|
|
124
|
-
let t =
|
|
124
|
+
let t = w;
|
|
125
125
|
return this.props.width !== void 0 ? t = this.props.width : this.props.initialWidth !== void 0 && (t = this.props.initialWidth), t;
|
|
126
126
|
}, this.getInitialHeight = () => {
|
|
127
|
-
let t =
|
|
127
|
+
let t = m;
|
|
128
128
|
return this.props.height !== void 0 ? t = this.props.height : this.props.initialHeight !== void 0 && (t = this.props.initialHeight), t;
|
|
129
129
|
}, this.handleMinimize = (t) => {
|
|
130
130
|
t.preventDefault(), this.windowCoordinatesState.leftBeforeAction = this.left, this.windowCoordinatesState.topBeforeAction = this.top, this.windowCoordinatesState.widthBeforeAction = this.width, this.windowCoordinatesState.heightBeforeAction = this.height, this.setState({
|
|
@@ -157,8 +157,8 @@ const u = 300, w = 300, m = 120, S = 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,
|
|
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, I = this.props.minHeight || E, T = 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 && I - (c + T) < 0 && (this.top > 0 && (g.height = c + T), g.top = p), e.direction.indexOf("s") >= 0 && I - 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,10 @@ const u = 300, w = 300, m = 120, S = 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 : F : this.state.zIndex > (this.context ? this.context + y : 0) ? this.state.zIndex : this.context + y, this.getDocument = () => {
|
|
183
|
+
const t = u ? document : null;
|
|
184
|
+
return this.props.appendTo ? this.props.appendTo.ownerDocument : t;
|
|
185
|
+
}, this.getWindow = () => {
|
|
183
186
|
const t = this.getDocument();
|
|
184
187
|
return t && t.defaultView;
|
|
185
188
|
}, this.state = {
|
|
@@ -187,11 +190,11 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
187
190
|
isDragging: !1,
|
|
188
191
|
top: 0,
|
|
189
192
|
left: 0,
|
|
190
|
-
width:
|
|
191
|
-
height:
|
|
193
|
+
width: w,
|
|
194
|
+
height: m,
|
|
192
195
|
focused: !0,
|
|
193
|
-
zIndex:
|
|
194
|
-
}, this.activeElement = document.activeElement;
|
|
196
|
+
zIndex: F
|
|
197
|
+
}, u && (this.activeElement = document.activeElement);
|
|
195
198
|
}
|
|
196
199
|
get _id() {
|
|
197
200
|
return this.props.id + "-accessibility-id";
|
|
@@ -210,7 +213,7 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
210
213
|
width: this.getInitialWidth(),
|
|
211
214
|
height: this.getInitialHeight(),
|
|
212
215
|
focused: !0,
|
|
213
|
-
zIndex:
|
|
216
|
+
zIndex: A(this.getCurrentZIndex(), this.getDocument(), this._id)
|
|
214
217
|
}), this.windowCoordinatesState = {
|
|
215
218
|
leftBeforeAction: this.getInitialLeft(),
|
|
216
219
|
topBeforeAction: this.getInitialTop(),
|
|
@@ -231,7 +234,7 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
231
234
|
const s = this.getWindow();
|
|
232
235
|
s && s.removeEventListener("resize", this.handleBrowserWindowResize), this.mounted = !1, setTimeout(() => {
|
|
233
236
|
var t;
|
|
234
|
-
!this.element && this.activeElement &&
|
|
237
|
+
!this.element && this.activeElement && u && (document.contains(this.activeElement) ? this.activeElement.focus({ preventScroll: !0 }) : this.activeElement.id && ((t = document.getElementById(this.activeElement.id)) == null || t.focus({ preventScroll: !0 })));
|
|
235
238
|
});
|
|
236
239
|
}
|
|
237
240
|
/**
|
|
@@ -250,11 +253,11 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
250
253
|
* @hidden
|
|
251
254
|
*/
|
|
252
255
|
render() {
|
|
253
|
-
const s = h.Children.toArray(this.props.children), t = this.getContent(s), e = this.getActionBar(s), o = this.getCurrentZIndex(), p =
|
|
256
|
+
const s = h.Children.toArray(this.props.children), t = this.getContent(s), e = this.getActionBar(s), o = this.getCurrentZIndex(), p = N("k-window", this.props.className, {
|
|
254
257
|
[`k-window-${this.props.themeColor}`]: this.props.themeColor,
|
|
255
258
|
"k-window-minimized": this.state.stage === "MINIMIZED",
|
|
256
259
|
"k-focus": this.state.focused
|
|
257
|
-
}), r = /* @__PURE__ */ h.createElement(
|
|
260
|
+
}), r = /* @__PURE__ */ h.createElement(M.Provider, { value: o }, /* @__PURE__ */ h.createElement(h.Fragment, null, this.props.modal && /* @__PURE__ */ h.createElement(
|
|
258
261
|
"div",
|
|
259
262
|
{
|
|
260
263
|
className: "k-overlay",
|
|
@@ -294,7 +297,7 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
294
297
|
isDragging: this.state.isDragging
|
|
295
298
|
},
|
|
296
299
|
/* @__PURE__ */ h.createElement(
|
|
297
|
-
|
|
300
|
+
U,
|
|
298
301
|
{
|
|
299
302
|
onPress: this.onPress,
|
|
300
303
|
onDrag: this.onDrag,
|
|
@@ -305,7 +308,7 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
305
308
|
}
|
|
306
309
|
},
|
|
307
310
|
/* @__PURE__ */ h.createElement(
|
|
308
|
-
|
|
311
|
+
R,
|
|
309
312
|
{
|
|
310
313
|
stage: this.windowStage,
|
|
311
314
|
onDoubleClick: this.props.doubleClickStageChange ? this.handleDoubleClick : void 0,
|
|
@@ -326,7 +329,7 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
326
329
|
this.windowStage === i.DEFAULT && this.props.resizable ? /* @__PURE__ */ h.createElement(_, { onResize: this.handleResize }) : null
|
|
327
330
|
)
|
|
328
331
|
)));
|
|
329
|
-
return
|
|
332
|
+
return u ? this.props.appendTo !== null ? B.createPortal(r, this.props.appendTo || document.body) : r : null;
|
|
330
333
|
}
|
|
331
334
|
// Getters
|
|
332
335
|
get top() {
|
|
@@ -359,10 +362,10 @@ const u = 300, w = 300, m = 120, S = 100, d = 5, f = class f extends h.Component
|
|
|
359
362
|
return this.props.stage || this.state.stage;
|
|
360
363
|
}
|
|
361
364
|
getActionBar(s) {
|
|
362
|
-
return s.filter((t) => t && t.type ===
|
|
365
|
+
return s.filter((t) => t && t.type === v);
|
|
363
366
|
}
|
|
364
367
|
getContent(s) {
|
|
365
|
-
return s.filter((t) => t && t.type !==
|
|
368
|
+
return s.filter((t) => t && t.type !== v);
|
|
366
369
|
}
|
|
367
370
|
generateTitleId() {
|
|
368
371
|
return "window-title-" + this._id;
|
|
@@ -390,24 +393,24 @@ f.displayName = "Window", f.propTypes = {
|
|
|
390
393
|
overlayStyle: n.object,
|
|
391
394
|
autoFocus: n.bool
|
|
392
395
|
}, f.defaultProps = {
|
|
393
|
-
minWidth:
|
|
394
|
-
minHeight:
|
|
396
|
+
minWidth: S,
|
|
397
|
+
minHeight: E,
|
|
395
398
|
resizable: !0,
|
|
396
399
|
draggable: !0,
|
|
397
400
|
modal: !1,
|
|
398
401
|
doubleClickStageChange: !0,
|
|
399
402
|
autoFocus: !0
|
|
400
|
-
}, f.contextType =
|
|
401
|
-
let
|
|
403
|
+
}, f.contextType = M;
|
|
404
|
+
let C = f;
|
|
402
405
|
const P = H(), K = z(
|
|
403
406
|
k(
|
|
404
407
|
P,
|
|
405
|
-
|
|
408
|
+
C
|
|
406
409
|
)
|
|
407
410
|
);
|
|
408
411
|
K.displayName = "KendoReactWindow";
|
|
409
412
|
export {
|
|
410
413
|
K as Window,
|
|
411
414
|
P as WindowPropsContext,
|
|
412
|
-
|
|
415
|
+
C as WindowWithoutContext
|
|
413
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,s,o,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 s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{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:s})=>l.createElement("div",{className:"k-window-titlebar k-dialog-titlebar",id:i},l.createElement("span",{className:"k-window-title k-dialog-title"},t),s&&l.createElement("div",{className:"k-window-titlebar-actions k-dialog-titlebar-actions"},l.createElement(o.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:s}=e,o=a.classNames("k-actions","k-actions-horizontal","k-window-actions k-dialog-actions",{[`k-actions-${i}`]:i});return l.createElement("div",{className:o},s)};c.propTypes={children:s.any,layout:s.oneOf(["start","center","end","stretched"])};const g="data-windowid",u=10002,m=(t,e,i)=>{let s=t;if(e&&e.defaultView){const t=e.querySelectorAll(".k-window:not(.k-dialog), .k-dialog-wrapper");let o=!1;return t.forEach((t=>{const n=e.defaultView.getComputedStyle(t,null);if(t.getAttribute(g)!==i&&null!==n.zIndex){const t=parseInt(n.zIndex,10);t>=s&&(s=t,o=!0)}})),o?s+2:s}return s},w=class extends l.Component{constructor(t){super(t),this.context=0,this.titleId=this.generateTitleId(),this.contentId=this.generateContentId(),this.activeElement=null,this.onCloseDialog=t=>{t.preventDefault(),a.dispatchEvent(this.props.onClose,t,this,void 0)},this.onKeyDown=t=>{t.keyCode===a.Keys.esc&&this.props.onClose&&(t.preventDefault(),this.onCloseDialog(t)),a.keepFocusInContainer(t,this.element)},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:u,this.getDocument=()=>this.props.appendTo?this.props.appendTo.ownerDocument:document,this.activeElement=a.getActiveElement(document)}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){if(this.element){if(this.props.autoFocus&&!this.props.autoFocusedElement)this.element.focus();else if(this.props.autoFocus&&this.props.autoFocusedElement)this.element.focus();else if(!this.props.autoFocus&&this.props.autoFocusedElement){const t=this.element.querySelector(this.props.autoFocusedElement);t&&t.focus()}else{const t=[...a.FOCUSABLE_ELEMENTS].map((t=>t+":not(.k-dialog-titlebar *)"));a.focusFirstFocusableChild(this.element,t)}this.setState({zIndex:m(this.getCurrentZIndex(),this.getDocument(),this._id)})}}componentWillUnmount(){setTimeout((()=>{var t;!this.element&&this.activeElement&&document&&(document.contains(this.activeElement)?this.activeElement.focus():this.activeElement.id&&(null==(t=document.getElementById(this.activeElement.id))||t.focus()))}))}render(){const t=void 0!==this.props.id?this.props.id:this.titleId,{title:e,width:i,height:s,children:o,minWidth:n,dir:r,style:h,contentStyle:c,modal:u=!0}=this.props,m=l.Children.toArray(o),w=this.getContent(m),f=this.getActionBar(m),E=e?{"aria-labelledby":t}:null,C=void 0===this.props.closeIcon||this.props.closeIcon,v=this.getCurrentZIndex(),S=l.createElement(a.ZIndexContext.Provider,{value:v},l.createElement("div",{[g]:this._id,className:"k-dialog-wrapper"+(this.props.className?" "+this.props.className:""),onKeyDown:this.onKeyDown,tabIndex:0,dir:r,style:{zIndex:v,...h},ref:t=>{this.element=t}},u&&l.createElement("div",{className:"k-overlay",style:this.props.overlayStyle}),l.createElement("div",{...E,className:a.classNames("k-window k-dialog",{[`k-window-${this.props.themeColor}`]:this.props.themeColor}),role:"dialog","aria-labelledby":t,"aria-modal":!0,"aria-describedby":this.contentId,style:{width:i,height:s,minWidth:n}},this.props.title&&l.createElement(p,{closeIcon:C,onCloseButtonClick:this.onCloseDialog,id:t},e),l.createElement("div",{className:"k-window-content k-dialog-content",style:c,id:this.contentId},w),f)));return a.canUseDOM?null!==this.props.appendTo?d.createPortal(S,this.props.appendTo||document.body):S:null}getActionBar(t){return t.filter((t=>t&&t.type===c))}getContent(t){return t.filter((t=>t&&t.type!==c))}generateTitleId(){return"dialog-title-"+this._id}generateContentId(){return"dialog-content-"+this._id}};w.displayName="Dialog",w.propTypes={title:s.any,id:s.string,dir:s.string,style:s.object,closeIcon:s.bool,width:s.oneOfType([s.number,s.string]),height:s.oneOfType([s.number,s.string]),minWidth:s.oneOfType([s.number,s.string]),autoFocus:s.bool},w.defaultProps={autoFocus:!1},w.contextType=a.ZIndexContext;let f=w;const E=a.createPropsContext(),C=a.withIdHOC(a.withPropsContext(E,f));C.displayName="KendoReactDialog";var v=(t=>(t.DEFAULT="DEFAULT",t.FULLSCREEN="FULLSCREEN",t.MINIMIZED="MINIMIZED",t))(v||{});const S="dialogs.windowMaximizeButton",I="dialogs.windowMinimizeButton",y="dialogs.windowRestoreButton",b="dialogs.windowCloseButton",k={[S]:"maximize",[I]:"minimize",[y]:"restore",[b]:"close"},D=t=>{const{children:e,onCloseButtonClick:i,onMinimizeButtonClick:s,onFullScreenButtonClick:a,onRestoreButtonClick:h,onDoubleClick:d,stage:p,forwardedRef:c,id:g}=t,u=r.useLocalization(),m=t.minimizeButton?l.createElement(t.minimizeButton,{onClick:s,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"window-minimize",svgIcon:n.windowMinimizeIcon,className:"k-window-titlebar-action",onClick:s,"aria-label":u.toLanguageString(I,k[I])}),w=t.maximizeButton?l.createElement(t.maximizeButton,{onClick:a,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"window-maximize",svgIcon:n.windowIcon,className:"k-window-titlebar-action",onClick:a,"aria-label":u.toLanguageString(S,k[S])}),f=t.restoreButton?l.createElement(t.restoreButton,{onClick:h,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"window-restore",svgIcon:n.windowRestoreIcon,className:"k-window-titlebar-action",onClick:h,"aria-label":u.toLanguageString(y,k[y])}),E=t.closeButton?l.createElement(t.closeButton,{onClick:i,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"x",svgIcon:n.xIcon,className:"k-window-titlebar-action",onClick:i,"aria-label":u.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:g},e||""),l.createElement("div",{className:"k-window-titlebar-actions"},p===v.DEFAULT&&m,p===v.DEFAULT&&w,p!==v.DEFAULT&&f,E))},T=l.forwardRef(((t,e)=>l.createElement(D,{...t,forwardedRef:e}))),x=["n","e","s","w","se","sw","ne","nw"];class B extends l.Component{render(){return l.createElement("div",{className:"k-resize-handles-wrapper"}," ",x.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 N=t=>{const e={layout:"end",...t},{layout:i,children:s}=e,o=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:o},s)};N.propTypes={children:s.any,layout:s.oneOf(["start","center","end","stretched"])};const F=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===v.MINIMIZED?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.DEFAULT})):this.windowStage===v.DEFAULT&&(this.handleFullscreen(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.FULLSCREEN}));break;case a.Keys.down:this.windowStage===v.FULLSCREEN?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.DEFAULT})):this.windowStage===v.DEFAULT&&(this.handleMinimize(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.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!==v.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!==v.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:v.MINIMIZED,height:0}),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.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,s=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:s,stage:v.FULLSCREEN}),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.FULLSCREEN})},this.handleRestore=t=>{t.preventDefault(),this.windowStage===v.FULLSCREEN?this.setState({stage:v.DEFAULT,left:this.windowCoordinatesState.leftBeforeAction,top:this.windowCoordinatesState.topBeforeAction,width:this.windowCoordinatesState.widthBeforeAction,height:this.windowCoordinatesState.heightBeforeAction}):this.windowStage===v.MINIMIZED&&this.setState({stage:v.DEFAULT,height:this.windowCoordinatesState.heightBeforeAction}),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.DEFAULT})},this.handleCloseWindow=t=>{t.preventDefault(),a.dispatchEvent(this.props.onClose,t,this,{state:void 0})},this.handleDoubleClick=t=>{this.windowStage===v.FULLSCREEN||this.windowStage===v.MINIMIZED?this.handleRestore(t):this.handleFullscreen(t)},this.handleResize=(t,e)=>{const i=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,s=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,o=this.width,n=this.height,a=this.props.minWidth||120,r=this.props.minHeight||100,h=this.top-s,l=this.left-i,d=i-this.left,p=s-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=s),e.direction.indexOf("s")>=0&&r-p<0&&(c.height=p),e.direction.indexOf("w")>=0&&a-(o+l)<0&&(this.left>0&&(c.width=o+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,s)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:i,end:s,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===v.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:u,this.getDocument=()=>this.props.appendTo?this.props.appendTo.ownerDocument:document,this.getWindow=()=>{const t=this.getDocument();return t&&t.defaultView},this.state={stage:this.props.stage||v.DEFAULT,isDragging:!1,top:0,left:0,width:300,height:300,focused:!0,zIndex:u},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||v.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&&document&&(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),s=this.getCurrentZIndex(),o=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:s},l.createElement(l.Fragment,null,this.props.modal&&l.createElement("div",{className:"k-overlay",style:{zIndex:s,...this.props.overlayStyle}}),l.createElement("div",{id:this.props.id,[g]: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:o,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:s,...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(T,{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!==v.MINIMIZED?l.createElement(l.Fragment,null,l.createElement("div",{className:"k-window-content"},e),i):null,this.windowStage===v.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!==v.FULLSCREEN?Math.max(this.props.top||this.state.top,0):0}get left(){return this.windowStage!==v.FULLSCREEN?Math.max(this.props.left||this.state.left,0):0}get width(){let t=this.props.width||this.state.width;if(this.windowStage===v.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===v.FULLSCREEN){if(this.props.appendTo)return t=this.props.appendTo.offsetHeight,t;const e=this.getWindow();t=e?e.innerHeight:0}else this.windowStage===v.MINIMIZED&&(t=0);return t}get windowStage(){return this.props.stage||this.state.stage}getActionBar(t){return t.filter((t=>t&&t.type===N))}getContent(t){return t.filter((t=>t&&t.type!==N))}generateTitleId(){return"window-title-"+this._id}};F.displayName="Window",F.propTypes={width:s.number,height:s.number,left:s.number,top:s.number,initialWidth:s.number,initialHeight:s.number,initialLeft:s.number,initialTop:s.number,minWidth:s.number,minHeight:s.number,resizable:s.bool,draggable:s.bool,title:s.any,shouldUpdateOnDrag:s.bool,stage:s.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),className:s.string,id:s.string,style:s.object,overlayStyle:s.object,autoFocus:s.bool},F.defaultProps={minWidth:120,minHeight:100,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},F.contextType=a.ZIndexContext;let z=F;const M=a.createPropsContext(),R=a.withIdHOC(a.withPropsContext(M,z));R.displayName="KendoReactWindow",t.Dialog=C,t.DialogActionsBar=c,t.DialogPropsContext=E,t.Window=R,t.WindowActionsBar=N,t.WindowPropsContext=M,t.WindowWithoutContext=z}));
|
|
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,s,o,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 s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{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:s})=>l.createElement("div",{className:"k-window-titlebar k-dialog-titlebar",id:i},l.createElement("span",{className:"k-window-title k-dialog-title"},t),s&&l.createElement("div",{className:"k-window-titlebar-actions k-dialog-titlebar-actions"},l.createElement(o.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:s}=e,o=a.classNames("k-actions","k-actions-horizontal","k-window-actions k-dialog-actions",{[`k-actions-${i}`]:i});return l.createElement("div",{className:o},s)};c.propTypes={children:s.any,layout:s.oneOf(["start","center","end","stretched"])};const g="data-windowid",u=10002,m=(t,e,i)=>{let s=t;if(e&&e.defaultView){const t=e.querySelectorAll(".k-window:not(.k-dialog), .k-dialog-wrapper");let o=!1;return t.forEach((t=>{const n=e.defaultView.getComputedStyle(t,null);if(t.getAttribute(g)!==i&&null!==n.zIndex){const t=parseInt(n.zIndex,10);t>=s&&(s=t,o=!0)}})),o?s+2:s}return s},w=class extends l.Component{constructor(t){super(t),this.context=0,this.titleId=this.generateTitleId(),this.contentId=this.generateContentId(),this.activeElement=null,this.onCloseDialog=t=>{t.preventDefault(),a.dispatchEvent(this.props.onClose,t,this,void 0)},this.onKeyDown=t=>{t.keyCode===a.Keys.esc&&this.props.onClose&&(t.preventDefault(),this.onCloseDialog(t)),a.keepFocusInContainer(t,this.element)},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:u,this.getDocument=()=>{const t=a.canUseDOM?document:null;return this.props.appendTo?this.props.appendTo.ownerDocument:t},a.canUseDOM&&(this.activeElement=a.getActiveElement(document))}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){if(this.element){if(this.props.autoFocus&&!this.props.autoFocusedElement)this.element.focus();else if(this.props.autoFocus&&this.props.autoFocusedElement)this.element.focus();else if(!this.props.autoFocus&&this.props.autoFocusedElement){const t=this.element.querySelector(this.props.autoFocusedElement);t&&t.focus()}else{const t=[...a.FOCUSABLE_ELEMENTS].map((t=>t+":not(.k-dialog-titlebar *)"));a.focusFirstFocusableChild(this.element,t)}this.setState({zIndex:m(this.getCurrentZIndex(),this.getDocument(),this._id)})}}componentWillUnmount(){setTimeout((()=>{var t;!this.element&&this.activeElement&&a.canUseDOM&&(document.contains(this.activeElement)?this.activeElement.focus():this.activeElement.id&&(null==(t=document.getElementById(this.activeElement.id))||t.focus()))}))}render(){const t=void 0!==this.props.id?this.props.id:this.titleId,{title:e,width:i,height:s,children:o,minWidth:n,dir:r,style:h,contentStyle:c,modal:u=!0}=this.props,m=l.Children.toArray(o),w=this.getContent(m),f=this.getActionBar(m),E=e?{"aria-labelledby":t}:null,C=void 0===this.props.closeIcon||this.props.closeIcon,v=this.getCurrentZIndex(),S=l.createElement(a.ZIndexContext.Provider,{value:v},l.createElement("div",{[g]:this._id,className:"k-dialog-wrapper"+(this.props.className?" "+this.props.className:""),onKeyDown:this.onKeyDown,tabIndex:0,dir:r,style:{zIndex:v,...h},ref:t=>{this.element=t}},u&&l.createElement("div",{className:"k-overlay",style:this.props.overlayStyle}),l.createElement("div",{...E,className:a.classNames("k-window k-dialog",{[`k-window-${this.props.themeColor}`]:this.props.themeColor}),role:"dialog","aria-labelledby":t,"aria-modal":!0,"aria-describedby":this.contentId,style:{width:i,height:s,minWidth:n}},this.props.title&&l.createElement(p,{closeIcon:C,onCloseButtonClick:this.onCloseDialog,id:t},e),l.createElement("div",{className:"k-window-content k-dialog-content",style:c,id:this.contentId},w),f)));return a.canUseDOM?null!==this.props.appendTo?d.createPortal(S,this.props.appendTo||document.body):S:null}getActionBar(t){return t.filter((t=>t&&t.type===c))}getContent(t){return t.filter((t=>t&&t.type!==c))}generateTitleId(){return"dialog-title-"+this._id}generateContentId(){return"dialog-content-"+this._id}};w.displayName="Dialog",w.propTypes={title:s.any,id:s.string,dir:s.string,style:s.object,closeIcon:s.bool,width:s.oneOfType([s.number,s.string]),height:s.oneOfType([s.number,s.string]),minWidth:s.oneOfType([s.number,s.string]),autoFocus:s.bool},w.defaultProps={autoFocus:!1},w.contextType=a.ZIndexContext;let f=w;const E=a.createPropsContext(),C=a.withIdHOC(a.withPropsContext(E,f));C.displayName="KendoReactDialog";var v=(t=>(t.DEFAULT="DEFAULT",t.FULLSCREEN="FULLSCREEN",t.MINIMIZED="MINIMIZED",t))(v||{});const S="dialogs.windowMaximizeButton",I="dialogs.windowMinimizeButton",y="dialogs.windowRestoreButton",b="dialogs.windowCloseButton",k={[S]:"maximize",[I]:"minimize",[y]:"restore",[b]:"close"},D=t=>{const{children:e,onCloseButtonClick:i,onMinimizeButtonClick:s,onFullScreenButtonClick:a,onRestoreButtonClick:h,onDoubleClick:d,stage:p,forwardedRef:c,id:g}=t,u=r.useLocalization(),m=t.minimizeButton?l.createElement(t.minimizeButton,{onClick:s,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"window-minimize",svgIcon:n.windowMinimizeIcon,className:"k-window-titlebar-action",onClick:s,"aria-label":u.toLanguageString(I,k[I])}),w=t.maximizeButton?l.createElement(t.maximizeButton,{onClick:a,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"window-maximize",svgIcon:n.windowIcon,className:"k-window-titlebar-action",onClick:a,"aria-label":u.toLanguageString(S,k[S])}),f=t.restoreButton?l.createElement(t.restoreButton,{onClick:h,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"window-restore",svgIcon:n.windowRestoreIcon,className:"k-window-titlebar-action",onClick:h,"aria-label":u.toLanguageString(y,k[y])}),E=t.closeButton?l.createElement(t.closeButton,{onClick:i,stage:p}):l.createElement(o.Button,{fillMode:"flat",icon:"x",svgIcon:n.xIcon,className:"k-window-titlebar-action",onClick:i,"aria-label":u.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:g},e||""),l.createElement("div",{className:"k-window-titlebar-actions"},p===v.DEFAULT&&m,p===v.DEFAULT&&w,p!==v.DEFAULT&&f,E))},T=l.forwardRef(((t,e)=>l.createElement(D,{...t,forwardedRef:e}))),x=["n","e","s","w","se","sw","ne","nw"];class B extends l.Component{render(){return l.createElement("div",{className:"k-resize-handles-wrapper"}," ",x.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 M=t=>{const e={layout:"end",...t},{layout:i,children:s}=e,o=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:o},s)};M.propTypes={children:s.any,layout:s.oneOf(["start","center","end","stretched"])};const 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===v.MINIMIZED?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.DEFAULT})):this.windowStage===v.DEFAULT&&(this.handleFullscreen(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.FULLSCREEN}));break;case a.Keys.down:this.windowStage===v.FULLSCREEN?(this.handleRestore(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.DEFAULT})):this.windowStage===v.DEFAULT&&(this.handleMinimize(t),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.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!==v.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!==v.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:v.MINIMIZED,height:0}),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.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,s=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:s,stage:v.FULLSCREEN}),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.FULLSCREEN})},this.handleRestore=t=>{t.preventDefault(),this.windowStage===v.FULLSCREEN?this.setState({stage:v.DEFAULT,left:this.windowCoordinatesState.leftBeforeAction,top:this.windowCoordinatesState.topBeforeAction,width:this.windowCoordinatesState.widthBeforeAction,height:this.windowCoordinatesState.heightBeforeAction}):this.windowStage===v.MINIMIZED&&this.setState({stage:v.DEFAULT,height:this.windowCoordinatesState.heightBeforeAction}),a.dispatchEvent(this.props.onStageChange,t,this,{state:v.DEFAULT})},this.handleCloseWindow=t=>{t.preventDefault(),a.dispatchEvent(this.props.onClose,t,this,{state:void 0})},this.handleDoubleClick=t=>{this.windowStage===v.FULLSCREEN||this.windowStage===v.MINIMIZED?this.handleRestore(t):this.handleFullscreen(t)},this.handleResize=(t,e)=>{const i=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,s=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,o=this.width,n=this.height,a=this.props.minWidth||120,r=this.props.minHeight||100,h=this.top-s,l=this.left-i,d=i-this.left,p=s-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=s),e.direction.indexOf("s")>=0&&r-p<0&&(c.height=p),e.direction.indexOf("w")>=0&&a-(o+l)<0&&(this.left>0&&(c.width=o+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,s)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:i,end:s,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===v.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:u,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||v.DEFAULT,isDragging:!1,top:0,left:0,width:300,height:300,focused:!0,zIndex:u},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||v.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),s=this.getCurrentZIndex(),o=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:s},l.createElement(l.Fragment,null,this.props.modal&&l.createElement("div",{className:"k-overlay",style:{zIndex:s,...this.props.overlayStyle}}),l.createElement("div",{id:this.props.id,[g]: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:o,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:s,...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(T,{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!==v.MINIMIZED?l.createElement(l.Fragment,null,l.createElement("div",{className:"k-window-content"},e),i):null,this.windowStage===v.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!==v.FULLSCREEN?Math.max(this.props.top||this.state.top,0):0}get left(){return this.windowStage!==v.FULLSCREEN?Math.max(this.props.left||this.state.left,0):0}get width(){let t=this.props.width||this.state.width;if(this.windowStage===v.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===v.FULLSCREEN){if(this.props.appendTo)return t=this.props.appendTo.offsetHeight,t;const e=this.getWindow();t=e?e.innerHeight:0}else this.windowStage===v.MINIMIZED&&(t=0);return t}get windowStage(){return this.props.stage||this.state.stage}getActionBar(t){return t.filter((t=>t&&t.type===M))}getContent(t){return t.filter((t=>t&&t.type!==M))}generateTitleId(){return"window-title-"+this._id}};N.displayName="Window",N.propTypes={width:s.number,height:s.number,left:s.number,top:s.number,initialWidth:s.number,initialHeight:s.number,initialLeft:s.number,initialTop:s.number,minWidth:s.number,minHeight:s.number,resizable:s.bool,draggable:s.bool,title:s.any,shouldUpdateOnDrag:s.bool,stage:s.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),className:s.string,id:s.string,style:s.object,overlayStyle:s.object,autoFocus:s.bool},N.defaultProps={minWidth:120,minHeight:100,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},N.contextType=a.ZIndexContext;let F=N;const z=a.createPropsContext(),R=a.withIdHOC(a.withPropsContext(z,F));R.displayName="KendoReactWindow",t.Dialog=C,t.DialogActionsBar=c,t.DialogPropsContext=E,t.Window=R,t.WindowActionsBar=M,t.WindowPropsContext=z,t.WindowWithoutContext=F}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-dialogs",
|
|
3
|
-
"version": "10.2.0
|
|
3
|
+
"version": "10.2.0",
|
|
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.5.1",
|
|
29
|
-
"@progress/kendo-react-buttons": "10.2.0
|
|
30
|
-
"@progress/kendo-react-common": "10.2.0
|
|
31
|
-
"@progress/kendo-react-intl": "10.2.0
|
|
29
|
+
"@progress/kendo-react-buttons": "10.2.0",
|
|
30
|
+
"@progress/kendo-react-common": "10.2.0",
|
|
31
|
+
"@progress/kendo-react-intl": "10.2.0",
|
|
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"
|