@progress/kendo-react-dialogs 14.5.0-develop.9 → 15.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dialog.js +1 -1
- package/Dialog.mjs +69 -69
- package/DialogProps.d.ts +6 -0
- package/DialogTitleBar.js +1 -1
- package/DialogTitleBar.mjs +27 -20
- package/README.md +4 -4
- package/Window.js +1 -1
- package/Window.mjs +226 -223
- package/WindowProps.d.ts +8 -0
- package/dist/cdn/js/kendo-react-dialogs.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +5 -5
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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react"),$=require("react-dom"),o=require("prop-types"),V=require("./DialogTitleBar.js"),z=require("./DialogActionsBar.js"),n=require("@progress/kendo-react-common"),T=require("./constants.js");function U(c){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const l in c)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(c,l);Object.defineProperty(i,l,a.get?a:{enumerable:!0,get:()=>c[l]})}}return i.default=c,Object.freeze(i)}const t=U(W),X=U($),G=n.createPropsContext(),k=t.forwardRef((c,i)=>{const l=n.useZIndexContext(),a=l?l+T.ZINDEX_DIALOGS_STEP:T.DEFAULT_DIALOGS_ZINDEX,b=t.useRef(null),r=t.useRef(null),u=t.useRef(n.getActiveElement(document)),p=n.usePropsContext(G,c),s=t.useMemo(()=>({...m,...p}),[p]),{title:D,width:S,height:M,children:f,minWidth:P,dir:_,style:h,contentStyle:x,autoFocusedElement:g,appendTo:A,className:C,overlayStyle:R,modal:I=m.modal,closeIcon:N=m.closeIcon,autoFocus:E=m.autoFocus}=s,w=t.useCallback(()=>({props:s,element:r.current}),[s]);t.useImperativeHandle(b,w),t.useImperativeHandle(i,()=>b.current),n.useWebMcpRegister("dialog",b,p,p.webMcp);const F=t.useMemo(()=>t.Children.toArray(f).filter(e=>!t.isValidElement(e)||e.type!==z.DialogActionsBar),[f]),j=t.useMemo(()=>t.Children.toArray(f).filter(e=>t.isValidElement(e)&&e.type===z.DialogActionsBar),[f]),{_id:q,contentId:v,id:O}=t.useMemo(()=>{const e=s.id,d=`${e!=null?e:"accessibility"}-id`,H=`dialog-title-${d}`,K=`dialog-content-${d}`;return{_id:d,contentId:K,id:e||H}},[s.id]),B=t.useCallback(()=>{if(r.current)if(E&&!g)r.current.focus();else if(!E&&g&&r.current){const e=r.current.querySelector(g);e==null||e.focus()}else{const e=[...n.FOCUSABLE_ELEMENTS].map(d=>d+":not(.k-dialog-titlebar *)");n.focusFirstFocusableChild(r.current,e)}},[E,g]);t.useEffect(()=>(B(),()=>{setTimeout(()=>{var e;!r.current&&u.current&&n.canUseDOM&&(document.contains(u.current)?u.current.focus():u.current.id&&((e=document.getElementById(u.current.id))==null||e.focus()))})}),[B]);const y=t.useCallback(e=>{e.preventDefault(),n.dispatchEvent(s.onClose,e,w(),void 0)},[s.onClose]),L=t.useCallback(e=>{e.keyCode===n.Keys.esc&&s.onClose&&(e.preventDefault(),y(e)),n.keepFocusInContainer(e,r.current)},[s.onClose,y]),Z=t.useMemo(()=>t.createElement(n.ZIndexContext.Provider,{value:a},t.createElement("div",{ref:r,[T.DATA_DIALOGS_ID]:q,className:"k-dialog-wrapper"+(C?" "+C:""),onKeyDown:L,tabIndex:0,dir:_,style:{zIndex:a,...h}},I&&t.createElement("div",{className:"k-overlay",style:R}),t.createElement("div",{className:n.classNames("k-window k-dialog"),role:"dialog","aria-labelledby":O,"aria-modal":I||void 0,"aria-describedby":v,style:{width:S,height:M,minWidth:P}},D&&t.createElement(V.DialogTitleBar,{closeIcon:N,onCloseButtonClick:y,id:O},D),t.createElement("div",{className:"k-window-content k-dialog-content",style:x,id:v},F),j))),[a,q,C,L,h,_,R,O,v,S,M,P,N,y,x,D,F,j,I]);return n.canUseDOM?A!==null?X.createPortal(Z,A||document.body):Z:null}),m={autoFocus:!1,modal:!0,closeIcon:!0},J={autoFocus:o.bool,autoFocusedElement:o.string,title:o.any,className:o.string,closeIcon:o.bool,modal:o.bool,overlayStyle:o.object,width:o.oneOfType([o.number,o.string]),height:o.oneOfType([o.number,o.string]),minWidth:o.oneOfType([o.number,o.string]),onClose:o.func,children:o.node,id:o.string,dir:o.string,style:o.object,contentStyle:o.object,appendTo:o.any};k.displayName="KendoReactDialog";k.propTypes=J;exports.Dialog=k;exports.DialogDefaultProps=m;exports.DialogPropsContext=G;
|
package/Dialog.mjs
CHANGED
|
@@ -10,31 +10,31 @@ import * as K from "react-dom";
|
|
|
10
10
|
import o from "prop-types";
|
|
11
11
|
import { DialogTitleBar as U } from "./DialogTitleBar.mjs";
|
|
12
12
|
import { DialogActionsBar as L } from "./DialogActionsBar.mjs";
|
|
13
|
-
import { useZIndexContext as
|
|
14
|
-
import { DEFAULT_DIALOGS_ZINDEX as
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
import { useZIndexContext as W, getActiveElement as $, usePropsContext as V, useWebMcpRegister as X, FOCUSABLE_ELEMENTS as q, focusFirstFocusableChild as J, canUseDOM as B, dispatchEvent as Q, Keys as Y, keepFocusInContainer as ee, ZIndexContext as te, classNames as oe, createPropsContext as ne } from "@progress/kendo-react-common";
|
|
14
|
+
import { DEFAULT_DIALOGS_ZINDEX as re, DATA_DIALOGS_ID as se, ZINDEX_DIALOGS_STEP as le } from "./constants.mjs";
|
|
15
|
+
const ce = ne(), Z = t.forwardRef((j, z) => {
|
|
16
|
+
const E = W(), m = E ? E + le : re, p = t.useRef(null), n = t.useRef(null), s = t.useRef($(document)), c = V(ce, j), r = t.useMemo(
|
|
17
17
|
() => ({
|
|
18
18
|
...u,
|
|
19
|
-
...
|
|
19
|
+
...c
|
|
20
20
|
}),
|
|
21
|
-
[
|
|
21
|
+
[c]
|
|
22
22
|
), {
|
|
23
|
-
title:
|
|
24
|
-
width:
|
|
25
|
-
height:
|
|
26
|
-
children:
|
|
23
|
+
title: f,
|
|
24
|
+
width: D,
|
|
25
|
+
height: v,
|
|
26
|
+
children: a,
|
|
27
27
|
minWidth: k,
|
|
28
|
-
dir:
|
|
29
|
-
style:
|
|
30
|
-
contentStyle:
|
|
31
|
-
autoFocusedElement:
|
|
32
|
-
appendTo:
|
|
33
|
-
className:
|
|
34
|
-
overlayStyle:
|
|
35
|
-
modal:
|
|
28
|
+
dir: T,
|
|
29
|
+
style: h,
|
|
30
|
+
contentStyle: x,
|
|
31
|
+
autoFocusedElement: i,
|
|
32
|
+
appendTo: S,
|
|
33
|
+
className: y,
|
|
34
|
+
overlayStyle: A,
|
|
35
|
+
modal: g = u.modal,
|
|
36
36
|
closeIcon: F = u.closeIcon,
|
|
37
|
-
autoFocus:
|
|
37
|
+
autoFocus: I = u.autoFocus
|
|
38
38
|
} = r, N = t.useCallback(
|
|
39
39
|
() => ({
|
|
40
40
|
props: r,
|
|
@@ -42,100 +42,100 @@ const le = oe(), Z = t.forwardRef((j, z) => {
|
|
|
42
42
|
}),
|
|
43
43
|
[r]
|
|
44
44
|
);
|
|
45
|
-
t.useImperativeHandle(
|
|
46
|
-
const w = t.useMemo(() => t.Children.toArray(
|
|
45
|
+
t.useImperativeHandle(p, N), t.useImperativeHandle(z, () => p.current), X("dialog", p, c, c.webMcp);
|
|
46
|
+
const w = t.useMemo(() => t.Children.toArray(a).filter(
|
|
47
47
|
(e) => !t.isValidElement(e) || e.type !== L
|
|
48
|
-
), [
|
|
48
|
+
), [a]), M = t.useMemo(() => t.Children.toArray(a).filter(
|
|
49
49
|
(e) => t.isValidElement(e) && e.type === L
|
|
50
|
-
), [
|
|
50
|
+
), [a]), { _id: R, contentId: C, id: b } = t.useMemo(() => {
|
|
51
51
|
const e = r.id, l = `${e != null ? e : "accessibility"}-id`, G = `dialog-title-${l}`, H = `dialog-content-${l}`;
|
|
52
52
|
return { _id: l, contentId: H, id: e || G };
|
|
53
|
-
}, [r.id]),
|
|
53
|
+
}, [r.id]), O = t.useCallback(() => {
|
|
54
54
|
if (n.current)
|
|
55
|
-
if (
|
|
55
|
+
if (I && !i)
|
|
56
56
|
n.current.focus();
|
|
57
|
-
else if (!
|
|
58
|
-
const e = n.current.querySelector(
|
|
57
|
+
else if (!I && i && n.current) {
|
|
58
|
+
const e = n.current.querySelector(i);
|
|
59
59
|
e == null || e.focus();
|
|
60
60
|
} else {
|
|
61
|
-
const e = [...
|
|
61
|
+
const e = [...q].map(
|
|
62
62
|
(l) => l + ":not(.k-dialog-titlebar *)"
|
|
63
63
|
);
|
|
64
|
-
|
|
64
|
+
J(n.current, e);
|
|
65
65
|
}
|
|
66
|
-
}, [
|
|
67
|
-
t.useEffect(() => (
|
|
66
|
+
}, [I, i]);
|
|
67
|
+
t.useEffect(() => (O(), () => {
|
|
68
68
|
setTimeout(() => {
|
|
69
69
|
var e;
|
|
70
70
|
!n.current && s.current && B && (document.contains(s.current) ? s.current.focus() : s.current.id && ((e = document.getElementById(s.current.id)) == null || e.focus()));
|
|
71
71
|
});
|
|
72
|
-
}), [
|
|
73
|
-
const
|
|
72
|
+
}), [O]);
|
|
73
|
+
const d = t.useCallback(
|
|
74
74
|
(e) => {
|
|
75
|
-
e.preventDefault(),
|
|
75
|
+
e.preventDefault(), Q(r.onClose, e, N(), void 0);
|
|
76
76
|
},
|
|
77
77
|
[r.onClose]
|
|
78
|
-
),
|
|
78
|
+
), P = t.useCallback(
|
|
79
79
|
(e) => {
|
|
80
|
-
e.keyCode ===
|
|
80
|
+
e.keyCode === Y.esc && r.onClose && (e.preventDefault(), d(e)), ee(e, n.current);
|
|
81
81
|
},
|
|
82
|
-
[r.onClose,
|
|
83
|
-
),
|
|
82
|
+
[r.onClose, d]
|
|
83
|
+
), _ = t.useMemo(() => /* @__PURE__ */ t.createElement(te.Provider, { value: m }, /* @__PURE__ */ t.createElement(
|
|
84
84
|
"div",
|
|
85
85
|
{
|
|
86
86
|
ref: n,
|
|
87
|
-
[
|
|
88
|
-
className: "k-dialog-wrapper" + (
|
|
89
|
-
onKeyDown:
|
|
87
|
+
[se]: R,
|
|
88
|
+
className: "k-dialog-wrapper" + (y ? " " + y : ""),
|
|
89
|
+
onKeyDown: P,
|
|
90
90
|
tabIndex: 0,
|
|
91
|
-
dir:
|
|
91
|
+
dir: T,
|
|
92
92
|
style: {
|
|
93
|
-
zIndex:
|
|
94
|
-
...
|
|
93
|
+
zIndex: m,
|
|
94
|
+
...h
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
|
|
97
|
+
g && /* @__PURE__ */ t.createElement("div", { className: "k-overlay", style: A }),
|
|
98
98
|
/* @__PURE__ */ t.createElement(
|
|
99
99
|
"div",
|
|
100
100
|
{
|
|
101
|
-
className:
|
|
101
|
+
className: oe("k-window k-dialog"),
|
|
102
102
|
role: "dialog",
|
|
103
|
-
"aria-labelledby":
|
|
104
|
-
"aria-modal":
|
|
105
|
-
"aria-describedby":
|
|
106
|
-
style: { width:
|
|
103
|
+
"aria-labelledby": b,
|
|
104
|
+
"aria-modal": g || void 0,
|
|
105
|
+
"aria-describedby": C,
|
|
106
|
+
style: { width: D, height: v, minWidth: k }
|
|
107
107
|
},
|
|
108
|
-
|
|
109
|
-
/* @__PURE__ */ t.createElement("div", { className: "k-window-content k-dialog-content", style:
|
|
110
|
-
|
|
108
|
+
f && /* @__PURE__ */ t.createElement(U, { closeIcon: F, onCloseButtonClick: d, id: b }, f),
|
|
109
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-window-content k-dialog-content", style: x, id: C }, w),
|
|
110
|
+
M
|
|
111
111
|
)
|
|
112
112
|
)), [
|
|
113
|
-
|
|
113
|
+
m,
|
|
114
|
+
R,
|
|
115
|
+
y,
|
|
114
116
|
P,
|
|
115
|
-
|
|
116
|
-
_,
|
|
117
|
+
h,
|
|
117
118
|
T,
|
|
118
|
-
|
|
119
|
-
S,
|
|
120
|
-
g,
|
|
121
|
-
y,
|
|
119
|
+
A,
|
|
122
120
|
b,
|
|
121
|
+
C,
|
|
123
122
|
D,
|
|
123
|
+
v,
|
|
124
124
|
k,
|
|
125
125
|
F,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
d,
|
|
127
|
+
x,
|
|
128
|
+
f,
|
|
129
129
|
w,
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
M,
|
|
131
|
+
g
|
|
132
132
|
]);
|
|
133
|
-
return B ?
|
|
133
|
+
return B ? S !== null ? K.createPortal(_, S || document.body) : _ : null;
|
|
134
134
|
}), u = {
|
|
135
135
|
autoFocus: !1,
|
|
136
136
|
modal: !0,
|
|
137
137
|
closeIcon: !0
|
|
138
|
-
},
|
|
138
|
+
}, ae = {
|
|
139
139
|
autoFocus: o.bool,
|
|
140
140
|
autoFocusedElement: o.string,
|
|
141
141
|
title: o.any,
|
|
@@ -155,9 +155,9 @@ const le = oe(), Z = t.forwardRef((j, z) => {
|
|
|
155
155
|
appendTo: o.any
|
|
156
156
|
};
|
|
157
157
|
Z.displayName = "KendoReactDialog";
|
|
158
|
-
Z.propTypes =
|
|
158
|
+
Z.propTypes = ae;
|
|
159
159
|
export {
|
|
160
160
|
Z as Dialog,
|
|
161
161
|
u as DialogDefaultProps,
|
|
162
|
-
|
|
162
|
+
ce as DialogPropsContext
|
|
163
163
|
};
|
package/DialogProps.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import { DialogCloseEvent } from './events';
|
|
9
|
+
import { WebMcpProps } from '@progress/kendo-react-common';
|
|
9
10
|
/**
|
|
10
11
|
* Represents the props of the [KendoReact Dialog component](https://www.telerik.com/kendo-react-ui/components/dialogs/dialog).
|
|
11
12
|
*/
|
|
@@ -173,4 +174,9 @@ export interface DialogProps {
|
|
|
173
174
|
* ```
|
|
174
175
|
*/
|
|
175
176
|
appendTo?: any;
|
|
177
|
+
/**
|
|
178
|
+
* Enables Web MCP tool registration for this component.
|
|
179
|
+
* Requires a parent `WebMcpProvider` from `@progress/kendo-react-webmcp`.
|
|
180
|
+
*/
|
|
181
|
+
webMcp?: boolean | WebMcpProps;
|
|
176
182
|
}
|
package/DialogTitleBar.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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),r=require("@progress/kendo-react-buttons"),s=require("@progress/kendo-react-intl"),d=require("@progress/kendo-svg-icons"),i=require("./messages/index.js");function u(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const n=u(c),g=({children:e,onCloseButtonClick:o,id:t,closeIcon:a})=>{const l=s.useLocalization();return n.createElement("div",{className:"k-window-titlebar k-dialog-titlebar",id:t},n.createElement("span",{className:"k-window-title k-dialog-title"},e),a&&n.createElement("div",{className:"k-window-titlebar-actions k-dialog-titlebar-actions"},n.createElement(r.Button,{"aria-label":l.toLanguageString(i.dialogsWindowCloseButton,i.messages[i.dialogsWindowCloseButton]),size:"xs",onClick:o,icon:"x",svgIcon:d.xIcon,fillMode:"flat",className:"k-window-titlebar-action k-dialog-titlebar-action"})))};exports.DialogTitleBar=g;
|
package/DialogTitleBar.mjs
CHANGED
|
@@ -6,26 +6,33 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as t from "react";
|
|
9
|
-
import { Button as
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
import { Button as r } from "@progress/kendo-react-buttons";
|
|
10
|
+
import { useLocalization as s } from "@progress/kendo-react-intl";
|
|
11
|
+
import { xIcon as c } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { dialogsWindowCloseButton as a, messages as m } from "./messages/index.mjs";
|
|
13
|
+
const b = ({
|
|
14
|
+
children: i,
|
|
15
|
+
onCloseButtonClick: o,
|
|
16
|
+
id: e,
|
|
15
17
|
closeIcon: l
|
|
16
|
-
}) =>
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
}) => {
|
|
19
|
+
const n = s();
|
|
20
|
+
return /* @__PURE__ */ t.createElement("div", { className: "k-window-titlebar k-dialog-titlebar", id: e }, /* @__PURE__ */ t.createElement("span", { className: "k-window-title k-dialog-title" }, i), l && /* @__PURE__ */ t.createElement("div", { className: "k-window-titlebar-actions k-dialog-titlebar-actions" }, /* @__PURE__ */ t.createElement(
|
|
21
|
+
r,
|
|
22
|
+
{
|
|
23
|
+
"aria-label": n.toLanguageString(
|
|
24
|
+
a,
|
|
25
|
+
m[a]
|
|
26
|
+
),
|
|
27
|
+
size: "xs",
|
|
28
|
+
onClick: o,
|
|
29
|
+
icon: "x",
|
|
30
|
+
svgIcon: c,
|
|
31
|
+
fillMode: "flat",
|
|
32
|
+
className: "k-window-titlebar-action k-dialog-titlebar-action"
|
|
33
|
+
}
|
|
34
|
+
)));
|
|
35
|
+
};
|
|
29
36
|
export {
|
|
30
|
-
|
|
37
|
+
b as DialogTitleBar
|
|
31
38
|
};
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[](https://www.telerik.com/kendo-react-ui/components/free?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs&utm_content=banner)
|
|
1
|
+
[](https://www.telerik.com/kendo-react-ui/components/getting-started/free-vs-premium?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs&utm_content=banner)
|
|
2
2
|
|
|
3
3
|
# KendoReact Dialogs Library for React
|
|
4
4
|
|
|
5
5
|
> **Important**
|
|
6
6
|
>
|
|
7
7
|
> - This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs)—an enterprise-grade UI library with 120+ free and premium components.
|
|
8
|
-
> - This package contains free KendoReact components. You can use it even in production, no sign-up or license required. If you're looking for more free React components, check out [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/
|
|
8
|
+
> - This package contains free KendoReact components. You can use it even in production, no sign-up or license required. If you're looking for more free React components, check out [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/getting-started).
|
|
9
9
|
> - Installing and working with this package indicates that you [accept the KendoReact License Agreement](https://www.telerik.com/purchase/license-agreement/progress-kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs).
|
|
10
10
|
> - The [30-day free trial](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs) gives you access to all KendoReact components and their full functionality. Additionally, for the period of your trial, you can use our legendary technical support provided directly by the KendoReact dev team!
|
|
11
11
|
|
|
@@ -100,7 +100,7 @@ import { Button } from '@progress/kendo-react-buttons'; // You can import any ot
|
|
|
100
100
|
|
|
101
101
|
The following table outlines the key resources available with KendoReact and KendoReact Free.
|
|
102
102
|
|
|
103
|
-
| | [KendoReact Free](https://www.telerik.com/kendo-react-ui/components/free)
|
|
103
|
+
| | [KendoReact Free](https://www.telerik.com/kendo-react-ui/components/getting-started/free-vs-premium) | [KendoReact](https://www.telerik.com/kendo-react-ui) |
|
|
104
104
|
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
105
105
|
| React components | 50+ | 120+ |
|
|
106
106
|
| Four professional themes | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" stroke="white" stroke-width="2"/></svg> | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" stroke="white" stroke-width="2"/></svg> |
|
|
@@ -123,7 +123,7 @@ For any issues you might encounter while working with the KendoReact Dialogs, us
|
|
|
123
123
|
## Resources
|
|
124
124
|
|
|
125
125
|
- [Getting Started with KendoReact](https://www.telerik.com/kendo-react-ui/components/getting-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs)
|
|
126
|
-
- [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/
|
|
126
|
+
- [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/getting-started)
|
|
127
127
|
- [Getting Started with the KendoReact Dialogs](https://www.telerik.com/kendo-react-ui/components/dialogs/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs)
|
|
128
128
|
- [API Reference of the KendoReact Dialogs](https://www.telerik.com/kendo-react-ui/components/dialogs/api/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs)
|
|
129
129
|
- [KendoReact Roadmap](https://www.telerik.com/support/whats-new/kendo-react-ui/roadmap?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-dialogs)
|
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 dt=require("react"),lt=require("react-dom"),i=require("prop-types"),ut=require("./WindowTitlebar.js"),a=require("@progress/kendo-react-common"),ft=require("./WindowResizeHandlers.js"),gt=require("./MiddleLayerOptimization.js"),o=require("./StageEnum.js"),Ze=require("./WindowActionsBar.js"),ee=require("./constants.js"),Ke=require("./utils.js");function Pe(e){const L=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const R in e)if(R!=="default"){const _=Object.getOwnPropertyDescriptor(e,R);Object.defineProperty(L,R,_.get?_:{enumerable:!0,get:()=>e[R]})}}return L.default=e,Object.freeze(L)}const m=Pe(dt),ht=Pe(lt),{useState:N,useEffect:O,useCallback:u,useMemo:X,useRef:U,useImperativeHandle:st,useContext:wt,forwardRef:Et}=m,te=300,ne=300,se=120,we=100,y=5,z={minWidth:se,minHeight:we,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},Ee=Et((e,L)=>{var Me;const{minWidth:R=z.minWidth,minHeight:_=z.minHeight,resizable:ue=z.resizable,draggable:me=z.draggable,modal:fe=z.modal,doubleClickStageChange:je=z.doubleClickStageChange,autoFocus:Xe=z.autoFocus}=e,[Ge,G]=N(e.stage||o.windowStage.DEFAULT),[V,ie]=N(!1),[oe,W]=N(0),[ae,v]=N(0),[ce,x]=N(te),[re,A]=N(ne),[Ve,ge]=N(!0),[he,Se]=N(ee.DEFAULT_DIALOGS_ZINDEX),r=(Me=e.stage)!=null?Me:Ge,M=wt(a.ZIndexContext),H=U(null),De=U(null),h=U({leftBeforeAction:0,topBeforeAction:0,widthBeforeAction:te,heightBeforeAction:ne}),Z=U({x:0,y:0}),K=U(void 0),Y=U(a.canUseDOM?document.activeElement:null),Le=U("window-title-"+(e.id?e.id+"-accessibility-id":"")),k=U({left:0,top:0,width:te,height:ne,internalLeft:ae,internalTop:oe,internalWidth:ce,internalHeight:re,stage:r,draggable:me,props:e}),F=u(()=>{const t=a.canUseDOM?document:null;return e.appendTo?e.appendTo.ownerDocument:t},[e.appendTo]),s=u(()=>{const t=F();return t==null?void 0:t.defaultView},[F]),P=X(()=>{var t;return r!==o.windowStage.FULLSCREEN?Math.max((t=e.top)!=null?t:oe,0):0},[r,e.top,oe]),q=X(()=>{var t;return r!==o.windowStage.FULLSCREEN?Math.max((t=e.left)!=null?t:ae,0):0},[r,e.left,ae]),C=X(()=>{var n;const t=(n=e.width)!=null?n:ce;if(r===o.windowStage.FULLSCREEN){if(e.appendTo)return e.appendTo.offsetWidth;const c=s();return c?c.innerWidth:0}return t},[r,e.width,e.appendTo,ce,s]),b=X(()=>{const t=e.height===void 0?re:e.height;if(r===o.windowStage.FULLSCREEN){if(e.appendTo)return e.appendTo.offsetHeight;const n=s();return n?n.innerHeight:0}else if(r===o.windowStage.MINIMIZED)return 0;return t},[r,e.height,e.appendTo,re,s]),de=X(()=>e.id?e.id+"-accessibility-id":void 0,[e.id]);O(()=>{k.current={left:q,top:P,width:C,height:b,internalLeft:ae,internalTop:oe,internalWidth:ce,internalHeight:re,stage:r,draggable:me,props:e}});const j=X(()=>{if(M===void 0)return M!=null?M:ee.DEFAULT_DIALOGS_ZINDEX;const t=M?M+ee.ZINDEX_DIALOGS_STEP:0;return he>t?he:M+ee.ZINDEX_DIALOGS_STEP},[he,M]),Ce=u(()=>{var c,l;if(e.top!==void 0)return e.top;if(e.initialTop!==void 0)return e.initialTop;let t=ne;if(e.height!==void 0?t=e.height:e.initialHeight!==void 0&&(t=e.initialHeight),e.appendTo&&t)return e.appendTo.offsetHeight/2-t/2;const n=s();return n?n.innerHeight/2-((l=t!=null?t:(c=H.current)==null?void 0:c.clientHeight)!=null?l:0)/2:0},[e.top,e.initialTop,e.height,e.initialHeight,e.appendTo,s]),be=u(()=>{if(e.left!==void 0)return e.left;if(e.initialLeft!==void 0)return e.initialLeft;let t=te;if(e.width!==void 0?t=e.width:e.initialWidth!==void 0&&(t=e.initialWidth),e.appendTo)return e.appendTo.offsetWidth/2-t/2;const n=s();return n?n.innerWidth/2-t/2:0},[e.left,e.initialLeft,e.width,e.initialWidth,e.appendTo,s]),Ie=u(()=>{let t=te;return e.width!==void 0?t=e.width:e.initialWidth!==void 0&&(t=e.initialWidth),t},[e.width,e.initialWidth]),ye=u(()=>{let t=ne;return e.height!==void 0?t=e.height:e.initialHeight!==void 0&&(t=e.initialHeight),t},[e.height,e.initialHeight]),Ye=u(t=>t.filter(n=>(n==null?void 0:n.type)===Ze.WindowActionsBar),[]),Je=u(t=>t.filter(n=>n&&n.type!==Ze.WindowActionsBar),[]),w=u(()=>typeof L=="object"&&L!==null&&"current"in L?L.current:null,[L]),B=u((t,n,c,l,d,f)=>{var D,Q,$;if(!t)return;const{internalLeft:S,internalTop:E,internalWidth:T,internalHeight:I}=k.current;t({nativeEvent:n.nativeEvent?n.nativeEvent:n.originalEvent,drag:c,end:l,target:w(),left:(D=d==null?void 0:d.left)!=null?D:S,top:(Q=d==null?void 0:d.top)!=null?Q:E,width:($=f==null?void 0:f.width)!=null?$:T,height:(f==null?void 0:f.height)===void 0?I:f==null?void 0:f.height})},[w]),Qe=u(t=>{var f,S;if(fe&&a.keepFocusInContainer(t,H.current),t.target!==t.currentTarget)return;const n=R||se,c=_||we,l=t.metaKey||t.ctrlKey,d=(S=b!=null?b:(f=H.current)==null?void 0:f.clientHeight)!=null?S:0;if(l&&ue){switch(t.keyCode){case a.Keys.up:t.preventDefault(),c<=d-y&&A(d-y);break;case a.Keys.down:t.preventDefault(),A(d+y);break;case a.Keys.left:n<=C-y&&x(C-y);break;case a.Keys.right:x(C+y);break;default:return}B(e.onResize,t,!1,void 0);return}if(t.altKey){switch(t.keyCode){case a.Keys.up:r===o.windowStage.MINIMIZED?(J(t),a.dispatchEvent(e.onStageChange,t,w(),{state:o.windowStage.DEFAULT})):r===o.windowStage.DEFAULT&&(le(t),a.dispatchEvent(e.onStageChange,t,w(),{state:o.windowStage.FULLSCREEN}));break;case a.Keys.down:r===o.windowStage.FULLSCREEN?(J(t),a.dispatchEvent(e.onStageChange,t,w(),{state:o.windowStage.DEFAULT})):r===o.windowStage.DEFAULT&&(We(t),a.dispatchEvent(e.onStageChange,t,w(),{state:o.windowStage.MINIMIZED}));break}return}if(!t.ctrlKey){const{internalLeft:E,internalTop:T}=k.current;let I=E,D=T;switch(t.keyCode){case a.Keys.esc:e.onClose&&ve(t);return;case a.Keys.up:D=T-y,W(D);break;case a.Keys.down:D=T+y,W(D);break;case a.Keys.left:I=E-y,v(I);break;case a.Keys.right:I=E+y,v(I);break;default:return}B(e.onMove,t,!1,void 0,{left:I,top:D})}},[fe,R,_,ue,e.onResize,e.onStageChange,e.onClose,e.onMove,b,C,r,B,w]),$e=u(t=>{const n=t.event,{left:c,top:l}=k.current;h.current.differenceLeft=n.pageX-c,h.current.differenceTop=n.pageY-l},[]),pe=u(t=>{const n=t.event;n.originalEvent.preventDefault();const{stage:c,draggable:l,props:d,width:f,height:S}=k.current;if(c!==o.windowStage.FULLSCREEN&&l){const E=Math.max(n.pageY-(h.current.differenceTop||0),0),T=n.pageX-(h.current.differenceLeft||0);W(E),v(T),ie(!0),d.onMove&&B(d.onMove,n,!0,!1,{left:T,top:E},{width:f,height:S})}},[B]),et=u(t=>{const n=t.event,{stage:c,draggable:l,props:d,left:f,top:S,width:E,height:T}=k.current;c!==o.windowStage.FULLSCREEN&&l&&d.onMove&&B(d.onMove,n,!0,!0,{left:f,top:S},{width:E,height:T}),ie(!1)},[B]),tt=u(()=>{K.current?(clearTimeout(K.current),K.current=void 0):(ge(!0),Se(Ke.getMaxZIndex(j,F(),de)))},[j,F,de]),nt=u(()=>{clearTimeout(K.current);const t=s();t&&(K.current=t.setTimeout(()=>{ge(!1),K.current=void 0}))},[s]),We=u(t=>{t.preventDefault(),h.current.leftBeforeAction=q,h.current.topBeforeAction=P,h.current.widthBeforeAction=C,h.current.heightBeforeAction=b,G(o.windowStage.MINIMIZED),A(0),a.dispatchEvent(e.onStageChange,t,w(),{state:o.windowStage.MINIMIZED})},[q,P,C,b,e.onStageChange,w]),le=u(t=>{t.preventDefault(),h.current.leftBeforeAction=q,h.current.topBeforeAction=P,h.current.widthBeforeAction=C,h.current.heightBeforeAction=b;const n=s(),c=n?n.innerWidth:0,l=n?n.innerHeight:0;v(0),W(0),x(e.appendTo?e.appendTo.offsetWidth:c),A(e.appendTo?e.appendTo.offsetHeight:l),G(o.windowStage.FULLSCREEN),a.dispatchEvent(e.onStageChange,t,w(),{state:o.windowStage.FULLSCREEN})},[q,P,C,b,e.appendTo,e.onStageChange,s,w]),J=u(t=>{t.preventDefault(),r===o.windowStage.FULLSCREEN?(G(o.windowStage.DEFAULT),v(h.current.leftBeforeAction),W(h.current.topBeforeAction),x(h.current.widthBeforeAction),A(h.current.heightBeforeAction)):r===o.windowStage.MINIMIZED&&(G(o.windowStage.DEFAULT),A(h.current.heightBeforeAction)),a.dispatchEvent(e.onStageChange,t,w(),{state:o.windowStage.DEFAULT})},[r,e.onStageChange,w]),ve=u(t=>{t.preventDefault(),a.dispatchEvent(e.onClose,t,w(),{state:void 0})},[e.onClose,w]),it=u(t=>{r===o.windowStage.FULLSCREEN||r===o.windowStage.MINIMIZED?J(t):le(t)},[r,J,le]),ot=u((t,n)=>{var Ue,xe,ke,Oe,ze,_e;const{props:c,width:l,height:d,top:f,left:S}=k.current,E=c.appendTo?t.pageX-Z.current.x:t.pageX,T=c.appendTo?t.pageY-Z.current.y:t.pageY,I=(xe=d!=null?d:(Ue=H.current)==null?void 0:Ue.clientHeight)!=null?xe:0,D=R||se,Q=_||we,$=f-T,He=S-E,Fe=E-S,Ne=T-f;let p=!1;const g={isDragging:!n.end};n.direction.indexOf("n")>=0&&Q-(I+$)<0&&(f>0&&(g.height=I+$),g.top=T,p=!0),n.direction.indexOf("s")>=0&&Q-Ne<0&&(g.height=Ne,p=!0),n.direction.indexOf("w")>=0&&D-(l+He)<0&&(S>0&&(g.width=l+He),g.left=E,p=!0),n.direction.indexOf("e")>=0&&D-Fe<0&&(g.width=Fe,p=!0),p&&(g.height!==void 0&&A(g.height),g.top!==void 0&&W(g.top),g.width!==void 0&&x(g.width),g.left!==void 0&&v(g.left),g.isDragging!==void 0&&ie(g.isDragging)),B(c.onResize,t,!0,n.end,{left:(ke=g.left)!=null?ke:S,top:(Oe=g.top)!=null?Oe:f},{width:(ze=g.width)!=null?ze:l,height:(_e=g.height)!=null?_e:d})},[B]),Ae=u(()=>{if(r===o.windowStage.FULLSCREEN){const t=s(),n=t?t.innerWidth:0,c=t?t.innerHeight:0;x(e.appendTo?e.appendTo.offsetWidth:n),A(e.appendTo?e.appendTo.offsetHeight:c)}},[r,e.appendTo,s]);O(()=>{const t=H.current;t&&Xe&&t.focus({preventScroll:!0});const n=s();n&&n.addEventListener("resize",Ae),G(e.stage||o.windowStage.DEFAULT),ie(!1),W(Ce()),v(be()),x(Ie()),A(ye()),ge(!0),Se(Ke.getMaxZIndex(j,F(),de)),h.current={leftBeforeAction:be(),topBeforeAction:Ce(),widthBeforeAction:Ie(),heightBeforeAction:ye()};const c=F();if(e.appendTo&&c){const l=e.appendTo.getBoundingClientRect(),d=c.body.getBoundingClientRect();Z.current.x=l.left-d.left,Z.current.y=l.top-d.top}return()=>{var d;const l=s();l&&l.removeEventListener("resize",Ae),Y.current&&a.canUseDOM&&(document.contains(Y.current)?Y.current.focus({preventScroll:!0}):Y.current.id&&((d=document.getElementById(Y.current.id))==null||d.focus({preventScroll:!0})))}},[]),O(()=>{e.left!==void 0&&!V&&v(e.left)},[e.left,V]),O(()=>{e.top!==void 0&&!V&&W(e.top)},[e.top,V]),O(()=>{e.initialLeft!==void 0&&v(e.initialLeft)},[e.initialLeft]),O(()=>{e.initialTop!==void 0&&W(e.initialTop)},[e.initialTop]),O(()=>{const t=F();if(e.appendTo&&t){const n=e.appendTo.getBoundingClientRect(),c=t.body.getBoundingClientRect();Z.current.x=n.left-c.left,Z.current.y=n.top-c.top}},[e.appendTo,F]),st(L,()=>({get element(){return H.current},get windowElement(){return H.current},get draggable(){return De.current},props:e}),[e]);const Be=m.Children.toArray(e.children),at=Je(Be),ct=Ye(Be),rt=a.classNames("k-window",e.className,{"k-window-minimized":r==="MINIMIZED","k-focus":Ve}),Re=m.createElement(a.ZIndexContext.Provider,{value:j},m.createElement(m.Fragment,null,fe&&m.createElement("div",{className:"k-overlay",style:{zIndex:j,...e.overlayStyle}}),m.createElement("div",{id:e.id,[ee.DATA_DIALOGS_ID]:de,tabIndex:0,role:"dialog","aria-labelledby":Le.current,onFocus:tt,onBlur:nt,onKeyDown:Qe,ref:H,className:rt,style:{top:P,left:q,width:C,height:b||"",zIndex:j,...e.style}},m.createElement(gt.MiddleLayerOptimization,{shouldUpdateOnDrag:e.shouldUpdateOnDrag||!1,isDragging:V},m.createElement(a.Draggable,{onPress:$e,onDrag:pe,onRelease:et,autoScroll:!1,ref:De},m.createElement(ut.WindowTitleBar,{stage:r,onDoubleClick:je?it:void 0,onMinimizeButtonClick:We,onFullScreenButtonClick:le,onRestoreButtonClick:J,onCloseButtonClick:ve,closeButton:e.closeButton,minimizeButton:e.minimizeButton,maximizeButton:e.maximizeButton,restoreButton:e.restoreButton,id:Le.current},e.title)),r===o.windowStage.MINIMIZED?null:m.createElement(m.Fragment,null,m.createElement("div",{className:"k-window-content"},at),ct),r===o.windowStage.DEFAULT&&ue?m.createElement(ft.ResizeHandlers,{onResize:ot}):null))));return a.canUseDOM?e.appendTo===null?Re:ht.createPortal(Re,e.appendTo||document.body):null});Ee.displayName="Window";const qe=a.createPropsContext(),Te=a.withIdHOC(a.withPropsContext(qe,Ee));Te.displayName="KendoReactWindow";const Tt={autoFocus:i.bool,title:i.any,className:i.string,closeButton:i.func,minimizeButton:i.func,maximizeButton:i.func,restoreButton:i.func,modal:i.bool,overlayStyle:i.object,width:i.number,height:i.number,minWidth:i.number,minHeight:i.number,left:i.number,top:i.number,initialLeft:i.number,initialTop:i.number,initialWidth:i.number,initialHeight:i.number,resizable:i.bool,draggable:i.bool,doubleClickStageChange:i.bool,stage:i.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),onClose:i.func,onMove:i.func,onResize:i.func,onStageChange:i.func,children:i.node,id:i.string,dir:i.string,style:i.object,appendTo:i.any,shouldUpdateOnDrag:i.bool};Te.propTypes=Tt;exports.Window=Te;exports.WindowPropsContext=qe;exports.WindowWithoutContext=Ee;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const lt=require("react"),ut=require("react-dom"),i=require("prop-types"),ft=require("./WindowTitlebar.js"),o=require("@progress/kendo-react-common"),gt=require("./WindowResizeHandlers.js"),ht=require("./MiddleLayerOptimization.js"),a=require("./StageEnum.js"),_e=require("./WindowActionsBar.js"),p=require("./constants.js"),Ze=require("./utils.js");function Ke(e){const D=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const y in e)if(y!=="default"){const x=Object.getOwnPropertyDescriptor(e,y);Object.defineProperty(D,y,x.get?x:{enumerable:!0,get:()=>e[y]})}}return D.default=e,Object.freeze(D)}const m=Ke(lt),st=Ke(ut),{useState:U,useEffect:z,useCallback:f,useMemo:X,useRef:H,useImperativeHandle:wt,useContext:Et,forwardRef:Tt}=m,ee=300,te=300,he=120,se=100,W=5,_={minWidth:he,minHeight:se,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0,autoFocus:!0},we=Tt((e,D)=>{var Me;const{minWidth:y=_.minWidth,minHeight:x=_.minHeight,resizable:le=_.resizable,draggable:Te=_.draggable,modal:ue=_.modal,doubleClickStageChange:qe=_.doubleClickStageChange,autoFocus:je=_.autoFocus}=e,[Xe,G]=U(e.stage||a.windowStage.DEFAULT),[V,ne]=U(!1),[ie,v]=U(0),[oe,A]=U(0),[ae,k]=U(ee),[ce,R]=U(te),[Ge,fe]=U(!0),[ge,me]=U(p.DEFAULT_DIALOGS_ZINDEX),r=(Me=e.stage)!=null?Me:Xe,F=Et(o.ZIndexContext),M=H(null),Se=H(null),h=H({leftBeforeAction:0,topBeforeAction:0,widthBeforeAction:ee,heightBeforeAction:te}),Z=H({x:0,y:0}),K=H(void 0),Ve=H(o.canUseDOM?document.activeElement:null),De=H("window-title-"+(e.id?e.id+"-accessibility-id":"")),O=H({left:0,top:0,width:ee,height:te,internalLeft:oe,internalTop:ie,internalWidth:ae,internalHeight:ce,stage:r,draggable:Te,props:e}),N=f(()=>{const t=o.canUseDOM?document:null;return e.appendTo?e.appendTo.ownerDocument:t},[e.appendTo]),s=f(()=>{const t=N();return t==null?void 0:t.defaultView},[N]),P=X(()=>{var t;return r!==a.windowStage.FULLSCREEN?Math.max((t=e.top)!=null?t:ie,0):0},[r,e.top,ie]),q=X(()=>{var t;return r!==a.windowStage.FULLSCREEN?Math.max((t=e.left)!=null?t:oe,0):0},[r,e.left,oe]),b=X(()=>{var n;const t=(n=e.width)!=null?n:ae;if(r===a.windowStage.FULLSCREEN){if(e.appendTo)return e.appendTo.offsetWidth;const c=s();return c?c.innerWidth:0}return t},[r,e.width,e.appendTo,ae,s]),C=X(()=>{const t=e.height===void 0?ce:e.height;if(r===a.windowStage.FULLSCREEN){if(e.appendTo)return e.appendTo.offsetHeight;const n=s();return n?n.innerHeight:0}else if(r===a.windowStage.MINIMIZED)return 0;return t},[r,e.height,e.appendTo,ce,s]),re=X(()=>e.id?e.id+"-accessibility-id":void 0,[e.id]);z(()=>{O.current={left:q,top:P,width:b,height:C,internalLeft:oe,internalTop:ie,internalWidth:ae,internalHeight:ce,stage:r,draggable:Te,props:e}});const j=X(()=>{if(F===void 0)return F!=null?F:p.DEFAULT_DIALOGS_ZINDEX;const t=F?F+p.ZINDEX_DIALOGS_STEP:0;return ge>t?ge:F+p.ZINDEX_DIALOGS_STEP},[ge,F]),Le=f(()=>{var c,u;if(e.top!==void 0)return e.top;if(e.initialTop!==void 0)return e.initialTop;let t=te;if(e.height!==void 0?t=e.height:e.initialHeight!==void 0&&(t=e.initialHeight),e.appendTo&&t)return e.appendTo.offsetHeight/2-t/2;const n=s();return n?n.innerHeight/2-((u=t!=null?t:(c=M.current)==null?void 0:c.clientHeight)!=null?u:0)/2:0},[e.top,e.initialTop,e.height,e.initialHeight,e.appendTo,s]),be=f(()=>{if(e.left!==void 0)return e.left;if(e.initialLeft!==void 0)return e.initialLeft;let t=ee;if(e.width!==void 0?t=e.width:e.initialWidth!==void 0&&(t=e.initialWidth),e.appendTo)return e.appendTo.offsetWidth/2-t/2;const n=s();return n?n.innerWidth/2-t/2:0},[e.left,e.initialLeft,e.width,e.initialWidth,e.appendTo,s]),Ce=f(()=>{let t=ee;return e.width!==void 0?t=e.width:e.initialWidth!==void 0&&(t=e.initialWidth),t},[e.width,e.initialWidth]),Ie=f(()=>{let t=te;return e.height!==void 0?t=e.height:e.initialHeight!==void 0&&(t=e.initialHeight),t},[e.height,e.initialHeight]),Ye=f(t=>t.filter(n=>(n==null?void 0:n.type)===_e.WindowActionsBar),[]),Je=f(t=>t.filter(n=>n&&n.type!==_e.WindowActionsBar),[]),w=f(()=>typeof D=="object"&&D!==null&&"current"in D?D.current:null,[D]),B=f((t,n,c,u,d,l)=>{var L,J,Q;if(!t)return;const{internalLeft:S,internalTop:E,internalWidth:T,internalHeight:I}=O.current;t({nativeEvent:n.nativeEvent?n.nativeEvent:n.originalEvent,drag:c,end:u,target:w(),left:(L=d==null?void 0:d.left)!=null?L:S,top:(J=d==null?void 0:d.top)!=null?J:E,width:(Q=l==null?void 0:l.width)!=null?Q:T,height:(l==null?void 0:l.height)===void 0?I:l==null?void 0:l.height})},[w]),Qe=f(t=>{var l,S;if(ue&&o.keepFocusInContainer(t,M.current),t.target!==t.currentTarget)return;const n=y||he,c=x||se,u=t.metaKey||t.ctrlKey,d=(S=C!=null?C:(l=M.current)==null?void 0:l.clientHeight)!=null?S:0;if(u&&le){switch(t.keyCode){case o.Keys.up:t.preventDefault(),c<=d-W&&R(d-W);break;case o.Keys.down:t.preventDefault(),R(d+W);break;case o.Keys.left:n<=b-W&&k(b-W);break;case o.Keys.right:k(b+W);break;default:return}B(e.onResize,t,!1,void 0);return}if(t.altKey){switch(t.keyCode){case o.Keys.up:r===a.windowStage.MINIMIZED?(Y(t),o.dispatchEvent(e.onStageChange,t,w(),{state:a.windowStage.DEFAULT})):r===a.windowStage.DEFAULT&&(de(t),o.dispatchEvent(e.onStageChange,t,w(),{state:a.windowStage.FULLSCREEN}));break;case o.Keys.down:r===a.windowStage.FULLSCREEN?(Y(t),o.dispatchEvent(e.onStageChange,t,w(),{state:a.windowStage.DEFAULT})):r===a.windowStage.DEFAULT&&(We(t),o.dispatchEvent(e.onStageChange,t,w(),{state:a.windowStage.MINIMIZED}));break}return}if(!t.ctrlKey){const{internalLeft:E,internalTop:T}=O.current;let I=E,L=T;switch(t.keyCode){case o.Keys.esc:e.onClose&&ye(t);return;case o.Keys.up:L=T-W,v(L);break;case o.Keys.down:L=T+W,v(L);break;case o.Keys.left:I=E-W,A(I);break;case o.Keys.right:I=E+W,A(I);break;default:return}B(e.onMove,t,!1,void 0,{left:I,top:L})}},[ue,y,x,le,e.onResize,e.onStageChange,e.onClose,e.onMove,C,b,r,B,w]),$e=f(t=>{const n=t.event,{left:c,top:u}=O.current;h.current.differenceLeft=n.pageX-c,h.current.differenceTop=n.pageY-u},[]),pe=f(t=>{const n=t.event;n.originalEvent.preventDefault();const{stage:c,draggable:u,props:d,width:l,height:S}=O.current;if(c!==a.windowStage.FULLSCREEN&&u){const E=Math.max(n.pageY-(h.current.differenceTop||0),0),T=n.pageX-(h.current.differenceLeft||0);v(E),A(T),ne(!0),d.onMove&&B(d.onMove,n,!0,!1,{left:T,top:E},{width:l,height:S})}},[B]),et=f(t=>{const n=t.event,{stage:c,draggable:u,props:d,left:l,top:S,width:E,height:T}=O.current;c!==a.windowStage.FULLSCREEN&&u&&d.onMove&&B(d.onMove,n,!0,!0,{left:l,top:S},{width:E,height:T}),ne(!1)},[B]),tt=f(()=>{K.current?(clearTimeout(K.current),K.current=void 0):(fe(!0),me(Ze.getMaxZIndex(j,N(),re)))},[j,N,re]),nt=f(()=>{clearTimeout(K.current);const t=s();t&&(K.current=t.setTimeout(()=>{fe(!1),K.current=void 0}))},[s]),We=f(t=>{t.preventDefault(),h.current.leftBeforeAction=q,h.current.topBeforeAction=P,h.current.widthBeforeAction=b,h.current.heightBeforeAction=C,G(a.windowStage.MINIMIZED),R(0),o.dispatchEvent(e.onStageChange,t,w(),{state:a.windowStage.MINIMIZED})},[q,P,b,C,e.onStageChange,w]),de=f(t=>{t.preventDefault(),h.current.leftBeforeAction=q,h.current.topBeforeAction=P,h.current.widthBeforeAction=b,h.current.heightBeforeAction=C;const n=s(),c=n?n.innerWidth:0,u=n?n.innerHeight:0;A(0),v(0),k(e.appendTo?e.appendTo.offsetWidth:c),R(e.appendTo?e.appendTo.offsetHeight:u),G(a.windowStage.FULLSCREEN),o.dispatchEvent(e.onStageChange,t,w(),{state:a.windowStage.FULLSCREEN})},[q,P,b,C,e.appendTo,e.onStageChange,s,w]),Y=f(t=>{t.preventDefault(),r===a.windowStage.FULLSCREEN?(G(a.windowStage.DEFAULT),A(h.current.leftBeforeAction),v(h.current.topBeforeAction),k(h.current.widthBeforeAction),R(h.current.heightBeforeAction)):r===a.windowStage.MINIMIZED&&(G(a.windowStage.DEFAULT),R(h.current.heightBeforeAction)),o.dispatchEvent(e.onStageChange,t,w(),{state:a.windowStage.DEFAULT})},[r,e.onStageChange,w]),ye=f(t=>{t.preventDefault(),o.dispatchEvent(e.onClose,t,w(),{state:void 0})},[e.onClose,w]),it=f(t=>{r===a.windowStage.FULLSCREEN||r===a.windowStage.MINIMIZED?Y(t):de(t)},[r,Y,de]),ot=f((t,n)=>{var Ne,Ue,xe,ke,Oe,ze;const{props:c,width:u,height:d,top:l,left:S}=O.current,E=c.appendTo?t.pageX-Z.current.x:t.pageX,T=c.appendTo?t.pageY-Z.current.y:t.pageY,I=(Ue=d!=null?d:(Ne=M.current)==null?void 0:Ne.clientHeight)!=null?Ue:0,L=y||he,J=x||se,Q=l-T,Be=S-E,He=E-S,Fe=T-l;let $=!1;const g={isDragging:!n.end};n.direction.indexOf("n")>=0&&J-(I+Q)<0&&(l>0&&(g.height=I+Q),g.top=T,$=!0),n.direction.indexOf("s")>=0&&J-Fe<0&&(g.height=Fe,$=!0),n.direction.indexOf("w")>=0&&L-(u+Be)<0&&(S>0&&(g.width=u+Be),g.left=E,$=!0),n.direction.indexOf("e")>=0&&L-He<0&&(g.width=He,$=!0),$&&(g.height!==void 0&&R(g.height),g.top!==void 0&&v(g.top),g.width!==void 0&&k(g.width),g.left!==void 0&&A(g.left),g.isDragging!==void 0&&ne(g.isDragging)),B(c.onResize,t,!0,n.end,{left:(xe=g.left)!=null?xe:S,top:(ke=g.top)!=null?ke:l},{width:(Oe=g.width)!=null?Oe:u,height:(ze=g.height)!=null?ze:d})},[B,x,y]),ve=f(()=>{if(r===a.windowStage.FULLSCREEN){const t=s(),n=t?t.innerWidth:0,c=t?t.innerHeight:0;k(e.appendTo?e.appendTo.offsetWidth:n),R(e.appendTo?e.appendTo.offsetHeight:c)}},[r,e.appendTo,s]);z(()=>{const t=M.current;t&&je&&t.focus({preventScroll:!0});const n=s();n&&n.addEventListener("resize",ve),G(e.stage||a.windowStage.DEFAULT),ne(!1),v(Le()),A(be()),k(Ce()),R(Ie()),fe(!0),me(Ze.getMaxZIndex(j,N(),re)),h.current={leftBeforeAction:be(),topBeforeAction:Le(),widthBeforeAction:Ce(),heightBeforeAction:Ie()};const c=N();if(e.appendTo&&c){const d=e.appendTo.getBoundingClientRect(),l=c.body.getBoundingClientRect();Z.current.x=d.left-l.left,Z.current.y=d.top-l.top}const u=Ve.current;return()=>{var l;const d=s();d&&d.removeEventListener("resize",ve),u&&o.canUseDOM&&(document.contains(u)?u.focus({preventScroll:!0}):u.id&&((l=document.getElementById(u.id))==null||l.focus({preventScroll:!0})))}},[]),z(()=>{e.left!==void 0&&!V&&A(e.left)},[e.left,V]),z(()=>{e.top!==void 0&&!V&&v(e.top)},[e.top,V]),z(()=>{e.initialLeft!==void 0&&A(e.initialLeft)},[e.initialLeft]),z(()=>{e.initialTop!==void 0&&v(e.initialTop)},[e.initialTop]),z(()=>{const t=N();if(e.appendTo&&t){const n=e.appendTo.getBoundingClientRect(),c=t.body.getBoundingClientRect();Z.current.x=n.left-c.left,Z.current.y=n.top-c.top}},[e.appendTo,N]);const at=H(null);wt(D,()=>({get element(){return M.current},get windowElement(){return M.current},get draggable(){return Se.current},props:e}),[e]),at.current=M.current,o.useWebMcpRegister("window",D,e,e.webMcp);const Ae=m.Children.toArray(e.children),ct=Je(Ae),rt=Ye(Ae),dt=o.classNames("k-window",e.className,{"k-window-minimized":r==="MINIMIZED","k-focus":Ge}),Re=m.createElement(o.ZIndexContext.Provider,{value:j},m.createElement(m.Fragment,null,ue&&m.createElement("div",{className:"k-overlay",style:{zIndex:j,...e.overlayStyle}}),m.createElement("div",{id:e.id,[p.DATA_DIALOGS_ID]:re,tabIndex:0,role:"dialog","aria-labelledby":De.current,onFocus:tt,onBlur:nt,onKeyDown:Qe,ref:M,className:dt,style:{top:P,left:q,width:b,height:C||"",zIndex:j,...e.style}},m.createElement(ht.MiddleLayerOptimization,{shouldUpdateOnDrag:e.shouldUpdateOnDrag||!1,isDragging:V},m.createElement(o.Draggable,{onPress:$e,onDrag:pe,onRelease:et,autoScroll:!1,ref:Se},m.createElement(ft.WindowTitleBar,{stage:r,onDoubleClick:qe?it:void 0,onMinimizeButtonClick:We,onFullScreenButtonClick:de,onRestoreButtonClick:Y,onCloseButtonClick:ye,closeButton:e.closeButton,minimizeButton:e.minimizeButton,maximizeButton:e.maximizeButton,restoreButton:e.restoreButton,id:De.current},e.title)),r===a.windowStage.MINIMIZED?null:m.createElement(m.Fragment,null,m.createElement("div",{className:"k-window-content"},ct),rt),r===a.windowStage.DEFAULT&&le?m.createElement(gt.ResizeHandlers,{onResize:ot}):null))));return o.canUseDOM?e.appendTo===null?Re:st.createPortal(Re,e.appendTo||document.body):null});we.displayName="Window";const Pe=o.createPropsContext(),Ee=o.withIdHOC(o.withPropsContext(Pe,we));Ee.displayName="KendoReactWindow";const mt={autoFocus:i.bool,title:i.any,className:i.string,closeButton:i.func,minimizeButton:i.func,maximizeButton:i.func,restoreButton:i.func,modal:i.bool,overlayStyle:i.object,width:i.number,height:i.number,minWidth:i.number,minHeight:i.number,left:i.number,top:i.number,initialLeft:i.number,initialTop:i.number,initialWidth:i.number,initialHeight:i.number,resizable:i.bool,draggable:i.bool,doubleClickStageChange:i.bool,stage:i.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),onClose:i.func,onMove:i.func,onResize:i.func,onStageChange:i.func,children:i.node,id:i.string,dir:i.string,style:i.object,appendTo:i.any,shouldUpdateOnDrag:i.bool};Ee.propTypes=mt;exports.Window=Ee;exports.WindowPropsContext=Pe;exports.WindowWithoutContext=we;
|