@progress/kendo-react-dialogs 7.2.4-develop.3 → 7.3.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 +8 -0
- package/Dialog.mjs +122 -0
- package/DialogActionsBar.js +8 -0
- package/DialogActionsBar.mjs +32 -0
- package/DialogTitleBar.js +8 -0
- package/DialogTitleBar.mjs +26 -0
- package/MiddleLayerOptimization.js +8 -0
- package/MiddleLayerOptimization.mjs +20 -0
- package/StageEnum.js +8 -0
- package/StageEnum.mjs +12 -0
- package/Window.js +8 -0
- package/Window.mjs +407 -0
- package/WindowActionsBar.js +8 -0
- package/WindowActionsBar.mjs +36 -0
- package/WindowResizeHandlers.js +8 -0
- package/WindowResizeHandlers.mjs +39 -0
- package/WindowTitlebar.js +8 -0
- package/WindowTitlebar.mjs +87 -0
- package/constants.js +8 -0
- package/constants.mjs +15 -0
- package/dist/cdn/js/kendo-react-dialogs.js +8 -5
- package/index.d.mts +599 -5
- package/index.d.ts +599 -13
- package/index.js +8 -5
- package/index.mjs +17 -687
- package/messages/index.js +8 -0
- package/messages/index.mjs +21 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +3 -3
- package/utils.js +8 -0
- package/utils.mjs +26 -0
- package/Dialog.d.ts +0 -94
- package/DialogActionsBar.d.ts +0 -25
- package/DialogProps.d.ts +0 -77
- package/DialogTitleBar.d.ts +0 -30
- package/MiddleLayerOptimization.d.ts +0 -21
- package/StageEnum.d.ts +0 -9
- package/Window.d.ts +0 -179
- package/WindowActionsBar.d.ts +0 -25
- package/WindowProps.d.ts +0 -151
- package/WindowResizeHandlers.d.ts +0 -20
- package/WindowTitlebar.d.ts +0 -67
- package/constants.d.ts +0 -12
- package/events.d.ts +0 -49
- package/messages/index.d.ts +0 -29
- package/models/actions-layout.d.ts +0 -8
- package/package-metadata.d.ts +0 -9
- package/utils.d.ts +0 -6
package/Dialog.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react"),P=require("react-dom"),t=require("prop-types"),_=require("./DialogTitleBar.js"),u=require("./DialogActionsBar.js"),n=require("@progress/kendo-react-common"),g=require("./package-metadata.js"),N=require("./utils.js"),c=require("./constants.js");function m(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(s,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}return s.default=r,Object.freeze(s)}const o=m(A),S=m(P),i=class i extends o.Component{constructor(s){super(s),this.context=0,this.titleId=this.generateTitleId(),this.contentId=this.generateContentId(),this.showLicenseWatermark=!1,this.onCloseDialog=e=>{e.preventDefault(),n.dispatchEvent(this.props.onClose,e,this,void 0)},this.onKeyDown=e=>{e.keyCode===n.Keys.esc&&this.props.onClose&&(e.preventDefault(),this.onCloseDialog(e)),n.keepFocusInContainer(e,this.element)},this.getCurrentZIndex=()=>!this.state||this.context===void 0?this.context?this.context:c.DEFAULT_DIALOGS_ZINDEX:this.state.zIndex>(this.context?this.context+c.ZINDEX_DIALOGS_STEP:0)?this.state.zIndex:this.context+c.ZINDEX_DIALOGS_STEP,this.getDocument=()=>this.props.appendTo?this.props.appendTo.ownerDocument:document,n.validatePackage(g.packageMetadata),this.showLicenseWatermark=n.shouldShowValidationUI(g.packageMetadata)}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){this.element&&(this.props.autoFocus&&this.element.focus(),this.setState({zIndex:N.getMaxZIndex(this.getCurrentZIndex(),this.getDocument(),this._id)}))}render(){const s=this.props.id!==void 0?this.props.id:this.titleId,{title:e,width:a,height:D,children:f,minWidth:b,dir:x,style:C,contentStyle:k}=this.props,d=o.Children.toArray(f),w=this.getContent(d),T=this.getActionBar(d),O=e?{"aria-labelledby":s}:null,E=this.props.closeIcon!==void 0?this.props.closeIcon:!0,p=this.getCurrentZIndex(),h=o.createElement(n.ZIndexContext.Provider,{value:p},o.createElement("div",{[c.DATA_DIALOGS_ID]:this._id,className:"k-dialog-wrapper"+(this.props.className?" "+this.props.className:""),onKeyDown:this.onKeyDown,tabIndex:0,dir:x,style:{zIndex:p,...C},ref:v=>this.element=v},o.createElement("div",{className:"k-overlay"}),o.createElement("div",{...O,className:n.classNames("k-window k-dialog",{[`k-window-${this.props.themeColor}`]:this.props.themeColor}),role:"dialog","aria-labelledby":s,"aria-modal":!0,"aria-describedby":this.contentId,style:{width:a,height:D,minWidth:b}},this.props.title&&o.createElement(_.DialogTitleBar,{closeIcon:E,onCloseButtonClick:this.onCloseDialog,id:s},e),o.createElement("div",{className:"k-window-content k-dialog-content",style:k,id:this.contentId},w),T,this.showLicenseWatermark&&o.createElement(n.WatermarkOverlay,null))));return n.canUseDOM?this.props.appendTo!==null?S.createPortal(h,this.props.appendTo||document.body):h:null}getActionBar(s){return s.filter(e=>e&&e.type===u.DialogActionsBar)}getContent(s){return s.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:t.any,id:t.string,dir:t.string,style:t.object,closeIcon:t.bool,width:t.oneOfType([t.number,t.string]),height:t.oneOfType([t.number,t.string]),minWidth:t.oneOfType([t.number,t.string]),autoFocus:t.bool},i.defaultProps={autoFocus:!1},i.contextType=n.ZIndexContext;let l=i;const y=n.createPropsContext(),I=n.withIdHOC(n.withPropsContext(y,l));I.displayName="KendoReactDialog";exports.Dialog=I;exports.DialogPropsContext=y;
|
package/Dialog.mjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as o from "react";
|
|
10
|
+
import * as b from "react-dom";
|
|
11
|
+
import e from "prop-types";
|
|
12
|
+
import { DialogTitleBar as E } from "./DialogTitleBar.mjs";
|
|
13
|
+
import { DialogActionsBar as c } from "./DialogActionsBar.mjs";
|
|
14
|
+
import { dispatchEvent as v, Keys as A, keepFocusInContainer as N, validatePackage as O, shouldShowValidationUI as P, ZIndexContext as d, classNames as Z, WatermarkOverlay as L, canUseDOM as S, createPropsContext as _, withIdHOC as B, withPropsContext as F } from "@progress/kendo-react-common";
|
|
15
|
+
import { packageMetadata as p } from "./package-metadata.mjs";
|
|
16
|
+
import { getMaxZIndex as K } from "./utils.mjs";
|
|
17
|
+
import { DEFAULT_DIALOGS_ZINDEX as M, ZINDEX_DIALOGS_STEP as h, DATA_DIALOGS_ID as z } from "./constants.mjs";
|
|
18
|
+
const i = class i extends o.Component {
|
|
19
|
+
constructor(s) {
|
|
20
|
+
super(s), this.context = 0, this.titleId = this.generateTitleId(), this.contentId = this.generateContentId(), this.showLicenseWatermark = !1, this.onCloseDialog = (t) => {
|
|
21
|
+
t.preventDefault(), v(this.props.onClose, t, this, void 0);
|
|
22
|
+
}, this.onKeyDown = (t) => {
|
|
23
|
+
t.keyCode === A.esc && this.props.onClose && (t.preventDefault(), this.onCloseDialog(t)), N(t, this.element);
|
|
24
|
+
}, 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 = () => this.props.appendTo ? this.props.appendTo.ownerDocument : document, O(p), this.showLicenseWatermark = P(p);
|
|
25
|
+
}
|
|
26
|
+
get _id() {
|
|
27
|
+
return this.props.id + "-accessibility-id";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
componentDidMount() {
|
|
33
|
+
this.element && (this.props.autoFocus && this.element.focus(), this.setState({
|
|
34
|
+
zIndex: K(this.getCurrentZIndex(), this.getDocument(), this._id)
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
40
|
+
render() {
|
|
41
|
+
const s = this.props.id !== void 0 ? this.props.id : this.titleId, { title: t, width: m, height: u, children: g, minWidth: I, dir: y, style: f, contentStyle: D } = this.props, r = o.Children.toArray(g), x = this.getContent(r), C = this.getActionBar(r), w = t ? {
|
|
42
|
+
"aria-labelledby": s
|
|
43
|
+
} : null, k = this.props.closeIcon !== void 0 ? this.props.closeIcon : !0, a = this.getCurrentZIndex(), l = /* @__PURE__ */ o.createElement(d.Provider, { value: a }, /* @__PURE__ */ o.createElement(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
[z]: this._id,
|
|
47
|
+
className: "k-dialog-wrapper" + (this.props.className ? " " + this.props.className : ""),
|
|
48
|
+
onKeyDown: this.onKeyDown,
|
|
49
|
+
tabIndex: 0,
|
|
50
|
+
dir: y,
|
|
51
|
+
style: {
|
|
52
|
+
zIndex: a,
|
|
53
|
+
...f
|
|
54
|
+
},
|
|
55
|
+
ref: (T) => this.element = T
|
|
56
|
+
},
|
|
57
|
+
/* @__PURE__ */ o.createElement("div", { className: "k-overlay" }),
|
|
58
|
+
/* @__PURE__ */ o.createElement(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
...w,
|
|
62
|
+
className: Z(
|
|
63
|
+
"k-window k-dialog",
|
|
64
|
+
{
|
|
65
|
+
[`k-window-${this.props.themeColor}`]: this.props.themeColor
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
role: "dialog",
|
|
69
|
+
"aria-labelledby": s,
|
|
70
|
+
"aria-modal": !0,
|
|
71
|
+
"aria-describedby": this.contentId,
|
|
72
|
+
style: { width: m, height: u, minWidth: I }
|
|
73
|
+
},
|
|
74
|
+
this.props.title && /* @__PURE__ */ o.createElement(
|
|
75
|
+
E,
|
|
76
|
+
{
|
|
77
|
+
closeIcon: k,
|
|
78
|
+
onCloseButtonClick: this.onCloseDialog,
|
|
79
|
+
id: s
|
|
80
|
+
},
|
|
81
|
+
t
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ o.createElement("div", { className: "k-window-content k-dialog-content", style: D, id: this.contentId }, x),
|
|
84
|
+
C,
|
|
85
|
+
this.showLicenseWatermark && /* @__PURE__ */ o.createElement(L, null)
|
|
86
|
+
)
|
|
87
|
+
));
|
|
88
|
+
return S ? this.props.appendTo !== null ? b.createPortal(l, this.props.appendTo || document.body) : l : null;
|
|
89
|
+
}
|
|
90
|
+
getActionBar(s) {
|
|
91
|
+
return s.filter((t) => t && t.type === c);
|
|
92
|
+
}
|
|
93
|
+
getContent(s) {
|
|
94
|
+
return s.filter((t) => t && t.type !== c);
|
|
95
|
+
}
|
|
96
|
+
generateTitleId() {
|
|
97
|
+
return "dialog-title-" + this._id;
|
|
98
|
+
}
|
|
99
|
+
generateContentId() {
|
|
100
|
+
return "dialog-content-" + this._id;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
i.displayName = "Dialog", i.propTypes = {
|
|
104
|
+
title: e.any,
|
|
105
|
+
id: e.string,
|
|
106
|
+
dir: e.string,
|
|
107
|
+
style: e.object,
|
|
108
|
+
closeIcon: e.bool,
|
|
109
|
+
width: e.oneOfType([e.number, e.string]),
|
|
110
|
+
height: e.oneOfType([e.number, e.string]),
|
|
111
|
+
minWidth: e.oneOfType([e.number, e.string]),
|
|
112
|
+
autoFocus: e.bool
|
|
113
|
+
}, i.defaultProps = {
|
|
114
|
+
autoFocus: !1
|
|
115
|
+
}, i.contextType = d;
|
|
116
|
+
let n = i;
|
|
117
|
+
const G = _(), R = B(F(G, n));
|
|
118
|
+
R.displayName = "KendoReactDialog";
|
|
119
|
+
export {
|
|
120
|
+
R as Dialog,
|
|
121
|
+
G as DialogPropsContext
|
|
122
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),c=require("prop-types"),i=require("@progress/kendo-react-common");function l(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const u=l(s),r=e=>{const o={layout:"stretched",...e},{layout:t,children:n}=o,a=i.classNames("k-actions","k-actions-horizontal","k-window-actions k-dialog-actions",{[`k-actions-${t}`]:t});return u.createElement("div",{className:a},n)};r.propTypes={children:c.any,layout:c.oneOf(["start","center","end","stretched"])};exports.DialogActionsBar=r;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as n from "react";
|
|
10
|
+
import t from "prop-types";
|
|
11
|
+
import { classNames as c } from "@progress/kendo-react-common";
|
|
12
|
+
const i = (e) => {
|
|
13
|
+
const s = {
|
|
14
|
+
layout: "stretched",
|
|
15
|
+
...e
|
|
16
|
+
}, { layout: o, children: a } = s, r = c(
|
|
17
|
+
"k-actions",
|
|
18
|
+
"k-actions-horizontal",
|
|
19
|
+
"k-window-actions k-dialog-actions",
|
|
20
|
+
{
|
|
21
|
+
[`k-actions-${o}`]: o
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ n.createElement("div", { className: r }, a);
|
|
25
|
+
};
|
|
26
|
+
i.propTypes = {
|
|
27
|
+
children: t.any,
|
|
28
|
+
layout: t.oneOf(["start", "center", "end", "stretched"])
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
i as DialogActionsBar
|
|
32
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),l=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-svg-icons");function c(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return a.default=e,Object.freeze(a)}const n=c(i),s=({children:e,onCloseButtonClick:a,id:t,closeIcon:o})=>n.createElement("div",{className:"k-window-titlebar k-dialog-titlebar",id:t},n.createElement("span",{className:"k-window-title k-dialog-title"},e),n.createElement("div",{className:"k-window-titlebar-actions k-dialog-titlebar-actions"},o&&n.createElement(l.Button,{role:"button","aria-label":"Close",onClick:a,icon:"x",svgIcon:r.xIcon,fillMode:"flat",className:"k-window-titlebar-action k-dialog-titlebar-action"})));exports.DialogTitleBar=s;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as t from "react";
|
|
10
|
+
import { Button as o } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { xIcon as n } from "@progress/kendo-svg-icons";
|
|
12
|
+
const s = ({ children: e, onCloseButtonClick: a, id: i, closeIcon: l }) => /* @__PURE__ */ t.createElement("div", { className: "k-window-titlebar k-dialog-titlebar", id: i }, /* @__PURE__ */ t.createElement("span", { className: "k-window-title k-dialog-title" }, e), /* @__PURE__ */ t.createElement("div", { className: "k-window-titlebar-actions k-dialog-titlebar-actions" }, l && /* @__PURE__ */ t.createElement(
|
|
13
|
+
o,
|
|
14
|
+
{
|
|
15
|
+
role: "button",
|
|
16
|
+
"aria-label": "Close",
|
|
17
|
+
onClick: a,
|
|
18
|
+
icon: "x",
|
|
19
|
+
svgIcon: n,
|
|
20
|
+
fillMode: "flat",
|
|
21
|
+
className: "k-window-titlebar-action k-dialog-titlebar-action"
|
|
22
|
+
}
|
|
23
|
+
)));
|
|
24
|
+
export {
|
|
25
|
+
s as DialogTitleBar
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const a=i(o);class c extends a.Component{shouldComponentUpdate(t){return t.shouldUpdateOnDrag||!t.isDragging}render(){return this.props.children}}exports.MiddleLayerOptimization=c;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as r from "react";
|
|
10
|
+
class n extends r.Component {
|
|
11
|
+
shouldComponentUpdate(e) {
|
|
12
|
+
return e.shouldUpdateOnDrag || !e.isDragging;
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
return this.props.children;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
n as MiddleLayerOptimization
|
|
20
|
+
};
|
package/StageEnum.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var E=(e=>(e.DEFAULT="DEFAULT",e.FULLSCREEN="FULLSCREEN",e.MINIMIZED="MINIMIZED",e))(E||{});exports.windowStage=E;
|
package/StageEnum.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
var I = /* @__PURE__ */ ((E) => (E.DEFAULT = "DEFAULT", E.FULLSCREEN = "FULLSCREEN", E.MINIMIZED = "MINIMIZED", E))(I || {});
|
|
10
|
+
export {
|
|
11
|
+
I as windowStage
|
|
12
|
+
};
|
package/Window.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),F=require("react-dom"),n=require("prop-types"),N=require("./WindowTitlebar.js"),o=require("@progress/kendo-react-common"),U=require("./WindowResizeHandlers.js"),k=require("./MiddleLayerOptimization.js"),s=require("./StageEnum.js"),y=require("./package-metadata.js"),M=require("./WindowActionsBar.js"),f=require("./constants.js"),A=require("./utils.js");function v(c){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(i,t,e.get?e:{enumerable:!0,get:()=>c[t]})}}return i.default=c,Object.freeze(i)}const a=v(x),z=v(F),u=300,S=300,m=120,E=100,r=5,g=class g extends a.Component{constructor(i){super(i),this.context=0,this.draggable=null,this.offSetCoordinates={x:0,y:0},this.titleId=this.generateTitleId(),this.mounted=!1,this.showLicenseWatermark=!1,this.onKeyDown=t=>{if(t.target!==t.currentTarget)return;const e=this.props.minWidth||m,h=this.props.minHeight||E;if(t.ctrlKey&&this.props.resizable){switch(t.keyCode){case o.Keys.up:t.preventDefault(),h<=this.height-r&&this.setState({height:this.height-r});break;case o.Keys.down:t.preventDefault(),this.setState({height:this.height+r});break;case o.Keys.left:e<=this.width-r&&this.setState({width:this.width-r});break;case o.Keys.right:this.setState({width:this.width+r});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({top:this.state.top-r});break;case o.Keys.down:this.setState({top:this.state.top+r});break;case o.Keys.left:this.setState({left:this.state.left-r});break;case o.Keys.right:this.setState({left:this.state.left+r});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:A.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=S;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=u;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=u;return this.props.width!==void 0?t=this.props.width:this.props.initialWidth!==void 0&&(t=this.props.initialWidth),t},this.getInitialHeight=()=>{let t=S;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(),h=e?e.innerWidth:0,d=e?e.innerHeight:0;this.setState({left:0,top:0,width:this.props.appendTo?this.props.appendTo.offsetWidth:h,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 h=this.props.appendTo?t.pageX-this.offSetCoordinates.x:t.pageX,d=this.props.appendTo?t.pageY-this.offSetCoordinates.y:t.pageY,w=this.width,p=this.height,C=this.props.minWidth||m,I=this.props.minHeight||E,T=this.top-d,L=this.left-h;let b=h-this.left,W=d-this.top;const l=Object.assign({},this.state,{isDragging:!e.end});e.direction.indexOf("n")>=0&&I-(p+T)<0&&(this.top>0&&(l.height=p+T),l.top=d),e.direction.indexOf("s")>=0&&I-W<0&&(l.height=W),e.direction.indexOf("w")>=0&&C-(w+L)<0&&(this.left>0&&(l.width=w+L),l.left=h),e.direction.indexOf("e")>=0&&C-b<0&&(l.width=b),this.setState(l),this.dispatchMoveEvent(this.props.onResize,t,!0,e.end)},this.dispatchMoveEvent=(t,e,h,d)=>{t&&t.call(void 0,{nativeEvent:e.nativeEvent?e.nativeEvent:e.originalEvent,drag:h,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,h=t?t.innerHeight:0;this.setState({width:this.props.appendTo?this.props.appendTo.offsetWidth:e,height:this.props.appendTo?this.props.appendTo.offsetHeight:h})}},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},o.validatePackage(y.packageMetadata),this.showLicenseWatermark=o.shouldShowValidationUI(y.packageMetadata),this.state={stage:this.props.stage||s.windowStage.DEFAULT,isDragging:!1,top:0,left:0,width:u,height:S,focused:!0,zIndex:f.DEFAULT_DIALOGS_ZINDEX}}get _id(){return this.props.id+"-accessibility-id"}componentDidMount(){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:A.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){let e=this.props.appendTo.getBoundingClientRect(),h=t.body.getBoundingClientRect();this.offSetCoordinates.x=e.left-h.left,this.offSetCoordinates.y=e.top-h.top}this.mounted=!0}componentWillUnmount(){const i=this.getWindow();i&&i.removeEventListener("resize",this.handleBrowserWindowResize),this.mounted=!1}componentDidUpdate(){const i=this.getDocument();if(this.props.appendTo&&i){let t=this.props.appendTo.getBoundingClientRect(),e=i.body.getBoundingClientRect();this.offSetCoordinates.x=t.left-e.left,this.offSetCoordinates.y=t.top-e.top}this.mounted=!0}render(){const i=a.Children.toArray(this.props.children),t=this.getContent(i),e=this.getActionBar(i),h=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-window-focused":this.state.focused}),w=a.createElement(o.ZIndexContext.Provider,{value:h},a.createElement(a.Fragment,null,this.props.modal&&a.createElement("div",{className:"k-overlay",style:{zIndex:h,...this.props.overlayStyle}}),a.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:p=>{this.windowElement=p,this.element=p},className:d,style:{top:this.top,left:this.left,width:this.width,height:this.height||"",zIndex:h,...this.props.style}},a.createElement(k.MiddleLayerOptimization,{shouldUpdateOnDrag:this.props.shouldUpdateOnDrag||!1,isDragging:this.state.isDragging},a.createElement(o.Draggable,{onPress:this.onPress,onDrag:this.onDrag,onRelease:this.onRelease,ref:p=>this.draggable=p},a.createElement(N.WindowTitleBar,{stage:this.windowStage,onDoubleClick:this.props.doubleClickStageChange?this.handleDoubleClick:void 0,onMinimizeButtonClick:this.handleMinimize,onFullScreenButtonClick:this.handleFullscreen,onRestoreButtonClick:this.handleRestore,onCloseButtonClick:this.handleCloseWindow,closeButton:this.props.closeButton,minimizeButton:this.props.minimizeButton,maximizeButton:this.props.maximizeButton,restoreButton:this.props.restoreButton,id:this.titleId},this.props.title)),this.windowStage!==s.windowStage.MINIMIZED?a.createElement(a.Fragment,null,a.createElement("div",{className:"k-window-content"},t),e):null,this.windowStage===s.windowStage.DEFAULT&&this.props.resizable?a.createElement(U.ResizeHandlers,{onResize:this.handleResize}):null),this.showLicenseWatermark&&a.createElement(o.WatermarkOverlay,null))));return o.canUseDOM?this.props.appendTo!==null?z.createPortal(w,this.props.appendTo||document.body):w: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===M.WindowActionsBar)}getContent(i){return i.filter(t=>t&&t.type!==M.WindowActionsBar)}generateTitleId(){return"window-title-"+this._id}};g.displayName="Window",g.propTypes={width:n.number,height:n.number,left:n.number,top:n.number,initialWidth:n.number,initialHeight:n.number,initialLeft:n.number,initialTop:n.number,minWidth:n.number,minHeight:n.number,resizable:n.bool,draggable:n.bool,title:n.any,shouldUpdateOnDrag:n.bool,stage:n.oneOf(["DEFAULT","MINIMIZED","FULLSCREEN"]),className:n.string,id:n.string,style:n.object,overlayStyle:n.object},g.defaultProps={minWidth:m,minHeight:E,resizable:!0,draggable:!0,modal:!1,doubleClickStageChange:!0},g.contextType=o.ZIndexContext;let D=g;const B=o.createPropsContext(),R=o.withIdHOC(o.withPropsContext(B,D));R.displayName="KendoReactWindow";exports.Window=R;exports.WindowPropsContext=B;
|