@progress/kendo-react-dialogs 4.13.0-dev.202111300702 → 4.13.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.
@@ -0,0 +1,2 @@
1
+ /* eslint-disable max-len */
2
+ // tslint:enable:max-line-length
@@ -11,13 +11,13 @@ interface WindowState {
11
11
  width: number;
12
12
  height: number;
13
13
  focused: boolean;
14
+ zIndex: number;
14
15
  }
15
16
  export declare class Window extends React.Component<WindowProps, WindowState> {
16
17
  /**
17
18
  * @hidden
18
19
  */
19
20
  static propTypes: {
20
- id: PropTypes.Requireable<string>;
21
21
  width: PropTypes.Requireable<string | number>;
22
22
  height: PropTypes.Requireable<string | number>;
23
23
  left: PropTypes.Requireable<string | number>;
@@ -35,6 +35,7 @@ export declare class Window extends React.Component<WindowProps, WindowState> {
35
35
  stage: PropTypes.Requireable<string>;
36
36
  className: PropTypes.Requireable<string>;
37
37
  style: PropTypes.Requireable<object>;
38
+ overlayStyle: PropTypes.Requireable<object>;
38
39
  };
39
40
  /**
40
41
  * @hidden
@@ -47,10 +48,18 @@ export declare class Window extends React.Component<WindowProps, WindowState> {
47
48
  modal: boolean;
48
49
  doubleClickStageChange: boolean;
49
50
  };
51
+ /**
52
+ * @hidden
53
+ */
54
+ static contextType: React.Context<number>;
55
+ /**
56
+ * **Deprecated.** Use `element` instead.
57
+ */
58
+ windowElement?: HTMLDivElement | null;
50
59
  /**
51
60
  * The Window element.
52
61
  */
53
- windowElement?: any;
62
+ element?: HTMLDivElement | null;
54
63
  /**
55
64
  * @hidden
56
65
  */
@@ -58,6 +67,8 @@ export declare class Window extends React.Component<WindowProps, WindowState> {
58
67
  draggable: Draggable | null;
59
68
  private windowCoordinatesState?;
60
69
  private offSetCoordinates?;
70
+ private _id;
71
+ private _blurTimeout?;
61
72
  constructor(props: WindowProps);
62
73
  /**
63
74
  * @hidden
@@ -71,6 +82,10 @@ export declare class Window extends React.Component<WindowProps, WindowState> {
71
82
  * @hidden
72
83
  */
73
84
  componentDidUpdate(): void;
85
+ /**
86
+ * @hidden
87
+ */
88
+ onKeyDown: (event: any) => void;
74
89
  /**
75
90
  * @hidden
76
91
  */
@@ -86,13 +101,20 @@ export declare class Window extends React.Component<WindowProps, WindowState> {
86
101
  /**
87
102
  * @hidden
88
103
  */
89
- render(): JSX.Element;
104
+ onFocus: () => void;
105
+ /**
106
+ * @hidden
107
+ */
108
+ onBlur: () => void;
109
+ /**
110
+ * @hidden
111
+ */
112
+ render(): React.ReactPortal;
90
113
  private readonly top;
91
114
  private readonly left;
92
115
  private readonly width;
93
116
  private readonly height;
94
117
  private readonly windowStage;
95
- private handleKeyDown;
96
118
  private getInitialTop;
97
119
  private getInitialLeft;
98
120
  private getInitialWidth;
@@ -107,6 +129,8 @@ export declare class Window extends React.Component<WindowProps, WindowState> {
107
129
  private handleBrowserWindowResize;
108
130
  private getActionBar;
109
131
  private getContent;
110
- private setZindex;
132
+ private getCurrentZIndex;
133
+ private getDocument;
134
+ private getWindow;
111
135
  }
112
136
  export {};
package/dist/es/Window.js CHANGED
@@ -26,7 +26,7 @@ import * as React from 'react';
26
26
  import * as ReactDOM from 'react-dom';
27
27
  import * as PropTypes from 'prop-types';
28
28
  import { WindowTitleBar } from './WindowTitlebar';
29
- import { dispatchEvent, Keys, classNames } from '@progress/kendo-react-common';
29
+ import { dispatchEvent, Keys, classNames, guid, ZIndexContext, canUseDOM } from '@progress/kendo-react-common';
30
30
  import { Draggable } from '@progress/kendo-react-common';
31
31
  import { ResizeHandlers } from './WindowResizeHandlers';
32
32
  import { MiddleLayerOptimization } from './MiddleLayerOptimization';
@@ -34,6 +34,8 @@ import { windowStage } from './StageEnum';
34
34
  import { validatePackage } from '@progress/kendo-react-common';
35
35
  import { packageMetadata } from './package-metadata';
36
36
  import { WindowActionsBar } from './WindowActionsBar';
37
+ import { DATA_DIALOGS_ID, DEFAULT_DIALOGS_ZINDEX, ZINDEX_DIALOGS_STEP } from './constants';
38
+ import { getMaxZIndex } from './utils';
37
39
  var DEFAULT_WIDTH = 300;
38
40
  var DEFAULT_HEIGHT = 300;
39
41
  var DEFAULT_MIN_WIDTH = 120;
@@ -44,48 +46,11 @@ var Window = /** @class */ (function (_super) {
44
46
  function Window(props) {
45
47
  var _this = _super.call(this, props) || this;
46
48
  _this.offSetCoordinates = { x: 0, y: 0 };
49
+ _this._id = guid();
47
50
  /**
48
51
  * @hidden
49
52
  */
50
- _this.onPress = function (data) {
51
- var e = data.event;
52
- _this.windowCoordinatesState.differenceLeft = e.pageX - _this.left;
53
- _this.windowCoordinatesState.differenceTop = e.pageY - _this.top;
54
- };
55
- /**
56
- * @hidden
57
- */
58
- _this.onDrag = function (data) {
59
- var e = data.event;
60
- e.originalEvent.preventDefault();
61
- if (_this.windowStage !== windowStage.FULLSCREEN && _this.props.draggable) {
62
- _this.setState({
63
- top: Math.max(e.pageY - _this.windowCoordinatesState.differenceTop, 0),
64
- left: e.pageX - _this.windowCoordinatesState.differenceLeft,
65
- isDragging: true
66
- });
67
- if (_this.props.onMove) {
68
- // eslint-disable-next-line max-len
69
- _this.dispatchMoveEvent(_this.props.onMove, e, true, false);
70
- }
71
- }
72
- };
73
- /**
74
- * @hidden
75
- */
76
- _this.onRelease = function (data) {
77
- var e = data.event;
78
- if (_this.windowStage !== windowStage.FULLSCREEN && _this.props.draggable) {
79
- if (_this.props.onMove) {
80
- _this.dispatchMoveEvent(_this.props.onMove, e, true, true);
81
- }
82
- }
83
- _this.setState({
84
- isDragging: false
85
- });
86
- };
87
- // Keyboard navigation
88
- _this.handleKeyDown = function (event) {
53
+ _this.onKeyDown = function (event) {
89
54
  if (event.target !== event.currentTarget) {
90
55
  return;
91
56
  }
@@ -166,6 +131,74 @@ var Window = /** @class */ (function (_super) {
166
131
  }
167
132
  _this.dispatchMoveEvent(_this.props.onMove, event, false, undefined);
168
133
  };
134
+ /**
135
+ * @hidden
136
+ */
137
+ _this.onPress = function (data) {
138
+ var e = data.event;
139
+ _this.windowCoordinatesState.differenceLeft = e.pageX - _this.left;
140
+ _this.windowCoordinatesState.differenceTop = e.pageY - _this.top;
141
+ };
142
+ /**
143
+ * @hidden
144
+ */
145
+ _this.onDrag = function (data) {
146
+ var e = data.event;
147
+ e.originalEvent.preventDefault();
148
+ if (_this.windowStage !== windowStage.FULLSCREEN && _this.props.draggable) {
149
+ _this.setState({
150
+ top: Math.max(e.pageY - _this.windowCoordinatesState.differenceTop, 0),
151
+ left: e.pageX - _this.windowCoordinatesState.differenceLeft,
152
+ isDragging: true
153
+ });
154
+ if (_this.props.onMove) {
155
+ // eslint-disable-next-line max-len
156
+ _this.dispatchMoveEvent(_this.props.onMove, e, true, false);
157
+ }
158
+ }
159
+ };
160
+ /**
161
+ * @hidden
162
+ */
163
+ _this.onRelease = function (data) {
164
+ var e = data.event;
165
+ if (_this.windowStage !== windowStage.FULLSCREEN && _this.props.draggable) {
166
+ if (_this.props.onMove) {
167
+ _this.dispatchMoveEvent(_this.props.onMove, e, true, true);
168
+ }
169
+ }
170
+ _this.setState({
171
+ isDragging: false
172
+ });
173
+ };
174
+ /**
175
+ * @hidden
176
+ */
177
+ _this.onFocus = function () {
178
+ if (_this._blurTimeout) {
179
+ clearTimeout(_this._blurTimeout);
180
+ _this._blurTimeout = undefined;
181
+ }
182
+ else {
183
+ _this.setState({
184
+ focused: true,
185
+ zIndex: getMaxZIndex(_this.getCurrentZIndex(), _this.getDocument(), _this._id)
186
+ });
187
+ }
188
+ };
189
+ /**
190
+ * @hidden
191
+ */
192
+ _this.onBlur = function () {
193
+ clearTimeout(_this._blurTimeout);
194
+ var currentWindow = _this.getWindow();
195
+ if (currentWindow) {
196
+ _this._blurTimeout = currentWindow.setTimeout(function () {
197
+ _this.setState({ focused: false });
198
+ _this._blurTimeout = undefined;
199
+ });
200
+ }
201
+ };
169
202
  // Get initial coordinates of the Window
170
203
  _this.getInitialTop = function () {
171
204
  if (_this.props.top !== undefined) {
@@ -184,7 +217,8 @@ var Window = /** @class */ (function (_super) {
184
217
  if (_this.props.appendTo) {
185
218
  return (_this.props.appendTo.offsetHeight / 2) - (height / 2);
186
219
  }
187
- return (window.innerHeight / 2) - (height / 2);
220
+ var currentWindow = _this.getWindow();
221
+ return currentWindow ? (currentWindow.innerHeight / 2) - (height / 2) : 0;
188
222
  };
189
223
  _this.getInitialLeft = function () {
190
224
  if (_this.props.left !== undefined) {
@@ -203,7 +237,8 @@ var Window = /** @class */ (function (_super) {
203
237
  if (_this.props.appendTo) {
204
238
  return (_this.props.appendTo.offsetWidth / 2) - (width / 2);
205
239
  }
206
- return (window.innerWidth / 2) - (width / 2);
240
+ var currentWindow = _this.getWindow();
241
+ return currentWindow ? (currentWindow.innerWidth / 2) - (width / 2) : 0;
207
242
  };
208
243
  _this.getInitialWidth = function () {
209
244
  var width = DEFAULT_WIDTH;
@@ -244,11 +279,14 @@ var Window = /** @class */ (function (_super) {
244
279
  _this.windowCoordinatesState.topBeforeAction = _this.top;
245
280
  _this.windowCoordinatesState.widthBeforeAction = _this.width;
246
281
  _this.windowCoordinatesState.heightBeforeAction = _this.height;
282
+ var currentWindow = _this.getWindow();
283
+ var innerWidth = currentWindow ? currentWindow.innerWidth : 0;
284
+ var innerHeight = currentWindow ? currentWindow.innerHeight : 0;
247
285
  _this.setState({
248
286
  left: 0,
249
287
  top: 0,
250
- width: _this.props.appendTo ? _this.props.appendTo.offsetWidth : window.innerWidth,
251
- height: _this.props.appendTo ? _this.props.appendTo.offsetHeight : window.innerHeight,
288
+ width: _this.props.appendTo ? _this.props.appendTo.offsetWidth : innerWidth,
289
+ height: _this.props.appendTo ? _this.props.appendTo.offsetHeight : innerHeight,
252
290
  stage: windowStage.FULLSCREEN
253
291
  });
254
292
  dispatchEvent(_this.props.onStageChange, event, _this, { state: windowStage.FULLSCREEN });
@@ -337,27 +375,27 @@ var Window = /** @class */ (function (_super) {
337
375
  };
338
376
  _this.handleBrowserWindowResize = function () {
339
377
  if (_this.windowStage === windowStage.FULLSCREEN) {
378
+ var currentWindow = _this.getWindow();
379
+ var innerWidth_1 = currentWindow ? currentWindow.innerWidth : 0;
380
+ var innerHeight_1 = currentWindow ? currentWindow.innerHeight : 0;
340
381
  _this.setState({
341
- width: _this.props.appendTo ? _this.props.appendTo.offsetWidth : window.innerWidth,
342
- height: _this.props.appendTo ? _this.props.appendTo.offsetHeight : window.innerHeight
382
+ width: _this.props.appendTo ? _this.props.appendTo.offsetWidth : innerWidth_1,
383
+ height: _this.props.appendTo ? _this.props.appendTo.offsetHeight : innerHeight_1
343
384
  });
344
385
  }
345
386
  };
346
- _this.setZindex = function () {
347
- if (_this.state.focused) {
348
- var allWindows = document && document.querySelectorAll('.k-window');
349
- var maxZindex_1 = 10002;
350
- allWindows.forEach(function (KRwindow) {
351
- var computedStyle = window.getComputedStyle(KRwindow, null);
352
- var zIndexValue = parseInt(computedStyle.zIndex !== null ? computedStyle.zIndex : '10002', 10);
353
- zIndexValue > maxZindex_1 ? maxZindex_1 = zIndexValue : null;
354
- });
355
- if (_this.windowElement && maxZindex_1.toString() === _this.windowElement.style.zIndex) {
356
- return _this.windowElement.style.zIndex;
357
- }
358
- return (maxZindex_1 + 1).toString();
387
+ _this.getCurrentZIndex = function () {
388
+ if (!_this.state) {
389
+ return _this.context ? _this.context : DEFAULT_DIALOGS_ZINDEX;
359
390
  }
360
- return _this.windowElement.style.zIndex;
391
+ return _this.state.zIndex > (_this.context ? _this.context + ZINDEX_DIALOGS_STEP : 0) ? _this.state.zIndex : _this.context + ZINDEX_DIALOGS_STEP;
392
+ };
393
+ _this.getDocument = function () {
394
+ return _this.props.appendTo ? _this.props.appendTo.ownerDocument : document;
395
+ };
396
+ _this.getWindow = function () {
397
+ var currentDocument = _this.getDocument();
398
+ return currentDocument && currentDocument.defaultView;
361
399
  };
362
400
  validatePackage(packageMetadata);
363
401
  _this.state = {
@@ -367,7 +405,8 @@ var Window = /** @class */ (function (_super) {
367
405
  left: _this.getInitialLeft(),
368
406
  width: _this.getInitialWidth(),
369
407
  height: _this.getInitialHeight(),
370
- focused: true
408
+ focused: true,
409
+ zIndex: getMaxZIndex(_this.getCurrentZIndex(), _this.getDocument(), _this._id)
371
410
  };
372
411
  _this.windowCoordinatesState = {
373
412
  leftBeforeAction: _this.getInitialLeft(),
@@ -381,12 +420,14 @@ var Window = /** @class */ (function (_super) {
381
420
  * @hidden
382
421
  */
383
422
  Window.prototype.componentDidMount = function () {
384
- if (window) {
385
- window.addEventListener('resize', this.handleBrowserWindowResize);
423
+ var currentWindow = this.getWindow();
424
+ if (currentWindow) {
425
+ currentWindow.addEventListener('resize', this.handleBrowserWindowResize);
386
426
  }
387
- if (this.props.appendTo) {
427
+ var currentDocument = this.getDocument();
428
+ if (this.props.appendTo && currentDocument) {
388
429
  var containerCoordinates = this.props.appendTo.getBoundingClientRect();
389
- var bodyRect = document.body.getBoundingClientRect();
430
+ var bodyRect = currentDocument.body.getBoundingClientRect();
390
431
  this.offSetCoordinates.x = containerCoordinates.left - bodyRect.left;
391
432
  this.offSetCoordinates.y = containerCoordinates.top - bodyRect.top;
392
433
  }
@@ -395,17 +436,19 @@ var Window = /** @class */ (function (_super) {
395
436
  * @hidden
396
437
  */
397
438
  Window.prototype.componentWillUnmount = function () {
398
- if (window) {
399
- window.removeEventListener('resize', this.handleBrowserWindowResize);
439
+ var currentWindow = this.getWindow();
440
+ if (currentWindow) {
441
+ currentWindow.removeEventListener('resize', this.handleBrowserWindowResize);
400
442
  }
401
443
  };
402
444
  /**
403
445
  * @hidden
404
446
  */
405
447
  Window.prototype.componentDidUpdate = function () {
406
- if (this.props.appendTo) {
448
+ var currentDocument = this.getDocument();
449
+ if (this.props.appendTo && currentDocument) {
407
450
  var containerCoordinates = this.props.appendTo.getBoundingClientRect();
408
- var bodyRect = document.body.getBoundingClientRect();
451
+ var bodyRect = currentDocument.body.getBoundingClientRect();
409
452
  this.offSetCoordinates.x = containerCoordinates.left - bodyRect.left;
410
453
  this.offSetCoordinates.y = containerCoordinates.top - bodyRect.top;
411
454
  }
@@ -415,29 +458,35 @@ var Window = /** @class */ (function (_super) {
415
458
  */
416
459
  Window.prototype.render = function () {
417
460
  var _this = this;
461
+ var _a;
418
462
  var elementsArray = React.Children.toArray(this.props.children);
419
463
  var content = this.getContent(elementsArray);
420
464
  var actions = this.getActionBar(elementsArray);
465
+ var currentZIndex = this.getCurrentZIndex();
421
466
  var classNamesWindow = classNames('k-widget', 'k-window', this.props.className, { 'k-window-minimized': this.state.stage === 'MINIMIZED' }, { 'k-window-focused': this.state.focused });
422
- var windowElement = (React.createElement(React.Fragment, null,
423
- this.props.modal && React.createElement("div", { className: "k-overlay" }),
424
- React.createElement("div", { tabIndex: 0, onFocus: function () { return _this.setState({ focused: true }); }, onBlur: function () { return _this.setState({ focused: false }); }, onKeyDown: this.handleKeyDown, ref: (function (el) { return _this.windowElement = el; }), className: classNamesWindow, style: __assign({ top: this.top, left: this.left, width: this.width, height: this.height || '', zIndex: this.setZindex() }, this.props.style) },
425
- React.createElement(MiddleLayerOptimization, { shouldUpdateOnDrag: this.props.shouldUpdateOnDrag || false, isDragging: this.state.isDragging },
426
- React.createElement(Draggable, { onPress: this.onPress, onDrag: this.onDrag, onRelease: this.onRelease, ref: function (component) { return _this.draggable = component; } },
427
- React.createElement(WindowTitleBar, { stage: this.windowStage, onDoubleClick: this.props.doubleClickStageChange ? this.handleDoubleClick : undefined, 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 }, this.props.title)),
428
- this.windowStage !== windowStage.MINIMIZED
429
- ? (React.createElement(React.Fragment, null,
430
- React.createElement("div", { className: "k-window-content" }, content),
431
- actions))
432
- : null,
433
- this.windowStage === windowStage.DEFAULT &&
434
- this.props.resizable
435
- ? React.createElement(ResizeHandlers, { onResize: this.handleResize })
436
- : null))));
437
- if (this.props.appendTo) {
438
- return ReactDOM.createPortal(windowElement, this.props.appendTo);
467
+ var windowElement = (React.createElement(ZIndexContext.Provider, { value: currentZIndex },
468
+ React.createElement(React.Fragment, null,
469
+ this.props.modal && (React.createElement("div", { className: "k-overlay", style: __assign({ zIndex: currentZIndex }, this.props.overlayStyle) })),
470
+ React.createElement("div", __assign({}, (_a = {}, _a[DATA_DIALOGS_ID] = this._id, _a), { tabIndex: 0, onFocus: this.onFocus, onBlur: this.onBlur, onKeyDown: this.onKeyDown, ref: function (el) {
471
+ _this.windowElement = el;
472
+ _this.element = el;
473
+ }, className: classNamesWindow, style: __assign({ top: this.top, left: this.left, width: this.width, height: this.height || '', zIndex: currentZIndex }, this.props.style) }),
474
+ React.createElement(MiddleLayerOptimization, { shouldUpdateOnDrag: this.props.shouldUpdateOnDrag || false, isDragging: this.state.isDragging },
475
+ React.createElement(Draggable, { onPress: this.onPress, onDrag: this.onDrag, onRelease: this.onRelease, ref: function (component) { return _this.draggable = component; } },
476
+ React.createElement(WindowTitleBar, { stage: this.windowStage, onDoubleClick: this.props.doubleClickStageChange ? this.handleDoubleClick : undefined, 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 }, this.props.title)),
477
+ this.windowStage !== windowStage.MINIMIZED
478
+ ? (React.createElement(React.Fragment, null,
479
+ React.createElement("div", { className: "k-window-content" }, content),
480
+ actions))
481
+ : null,
482
+ this.windowStage === windowStage.DEFAULT &&
483
+ this.props.resizable
484
+ ? React.createElement(ResizeHandlers, { onResize: this.handleResize })
485
+ : null)))));
486
+ if (canUseDOM) {
487
+ return ReactDOM.createPortal(windowElement, this.props.appendTo || document.body);
439
488
  }
440
- return windowElement;
489
+ return null;
441
490
  };
442
491
  Object.defineProperty(Window.prototype, "top", {
443
492
  // Getters
@@ -468,7 +517,8 @@ var Window = /** @class */ (function (_super) {
468
517
  width = this.props.appendTo.offsetWidth;
469
518
  return width;
470
519
  }
471
- width = window.innerWidth;
520
+ var currentWindow = this.getWindow();
521
+ width = currentWindow ? currentWindow.innerWidth : 0;
472
522
  }
473
523
  return width;
474
524
  },
@@ -483,7 +533,8 @@ var Window = /** @class */ (function (_super) {
483
533
  height = this.props.appendTo.offsetHeight;
484
534
  return height;
485
535
  }
486
- height = window.innerHeight;
536
+ var currentWindow = this.getWindow();
537
+ height = currentWindow ? currentWindow.innerHeight : 0;
487
538
  }
488
539
  else if (this.windowStage === windowStage.MINIMIZED) {
489
540
  height = 0;
@@ -512,7 +563,6 @@ var Window = /** @class */ (function (_super) {
512
563
  * @hidden
513
564
  */
514
565
  Window.propTypes = {
515
- id: PropTypes.string,
516
566
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
517
567
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
518
568
  left: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -529,7 +579,8 @@ var Window = /** @class */ (function (_super) {
529
579
  shouldUpdateOnDrag: PropTypes.bool,
530
580
  stage: PropTypes.oneOf(['DEFAULT', 'MINIMIZED', 'FULLSCREEN']),
531
581
  className: PropTypes.string,
532
- style: PropTypes.object
582
+ style: PropTypes.object,
583
+ overlayStyle: PropTypes.object
533
584
  };
534
585
  /**
535
586
  * @hidden
@@ -542,6 +593,10 @@ var Window = /** @class */ (function (_super) {
542
593
  modal: false,
543
594
  doubleClickStageChange: true
544
595
  };
596
+ /**
597
+ * @hidden
598
+ */
599
+ Window.contextType = ZIndexContext;
545
600
  return Window;
546
601
  }(React.Component));
547
602
  export { Window };
@@ -106,6 +106,10 @@ export interface WindowProps {
106
106
  * Set styles to the Window element.
107
107
  */
108
108
  style?: React.CSSProperties;
109
+ /**
110
+ * Set styles to the Window overlay element rendered when the `modal` prop is enabled.
111
+ */
112
+ overlayStyle?: React.CSSProperties;
109
113
  /**
110
114
  * Sets a class of the Window DOM element.
111
115
  */
@@ -0,0 +1,8 @@
1
+ /** @hidden */
2
+ export declare const DATA_DIALOGS_ID = "data-windowid";
3
+ /** @hidden */
4
+ export declare const DEFAULT_DIALOGS_ZINDEX = 10002;
5
+ /** @hidden */
6
+ export declare const ZINDEX_DIALOGS_STEP = 2;
7
+ /** @hidden */
8
+ export declare const DIALOGS_SELECTOR = ".k-window:not(.k-dialog), .k-dialog-wrapper";
@@ -0,0 +1,8 @@
1
+ /** @hidden */
2
+ export var DATA_DIALOGS_ID = 'data-windowid';
3
+ /** @hidden */
4
+ export var DEFAULT_DIALOGS_ZINDEX = 10002;
5
+ /** @hidden */
6
+ export var ZINDEX_DIALOGS_STEP = 2;
7
+ /** @hidden */
8
+ export var DIALOGS_SELECTOR = '.k-window:not(.k-dialog), .k-dialog-wrapper';
package/dist/es/main.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Dialog, DialogProps } from './Dialog';
1
+ import { Dialog } from './Dialog';
2
2
  import { DialogActionsBar } from './DialogActionsBar';
3
3
  import { Window } from './Window';
4
4
  import { WindowProps } from './WindowProps';
5
5
  import { WindowActionsBar } from './WindowActionsBar';
6
6
  import { DialogCloseEvent, WindowActionsEvent, WindowMoveEvent } from './events';
7
7
  import { ActionsLayout } from './models/actions-layout';
8
+ import { DialogProps } from './DialogProps';
8
9
  export { Dialog, DialogProps, DialogActionsBar, DialogCloseEvent, Window, WindowProps, WindowActionsBar, WindowActionsEvent, WindowMoveEvent, ActionsLayout };
@@ -5,7 +5,7 @@ export var packageMetadata = {
5
5
  name: '@progress/kendo-react-dialogs',
6
6
  productName: 'KendoReact',
7
7
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1638254659,
8
+ publishDate: 1638880453,
9
9
  version: '',
10
10
  licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
11
  };
@@ -0,0 +1,2 @@
1
+ /** @hidden */
2
+ export declare const getMaxZIndex: (currentZIndex: number, currentDocument: Document, currentWindowId: string) => number;
@@ -0,0 +1,22 @@
1
+ import { DATA_DIALOGS_ID, DIALOGS_SELECTOR, ZINDEX_DIALOGS_STEP } from './constants';
2
+ /** @hidden */
3
+ export var getMaxZIndex = function (currentZIndex, currentDocument, currentWindowId) {
4
+ var maxZindex = currentZIndex;
5
+ if (currentDocument && currentDocument.defaultView) {
6
+ var allWindows = currentDocument.querySelectorAll(DIALOGS_SELECTOR);
7
+ var zIndexChanged_1 = false;
8
+ allWindows.forEach(function (KRwindow) {
9
+ var computedStyle = currentDocument.defaultView.getComputedStyle(KRwindow, null);
10
+ var dataId = KRwindow.getAttribute(DATA_DIALOGS_ID);
11
+ if (dataId !== currentWindowId && computedStyle.zIndex !== null) {
12
+ var zIndexValue = parseInt(computedStyle.zIndex, 10);
13
+ if (zIndexValue >= maxZindex) {
14
+ maxZindex = zIndexValue;
15
+ zIndexChanged_1 = true;
16
+ }
17
+ }
18
+ });
19
+ return zIndexChanged_1 ? (maxZindex + ZINDEX_DIALOGS_STEP) : maxZindex;
20
+ }
21
+ return maxZindex;
22
+ };
@@ -1,68 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
- import { DialogCloseEvent } from './events';
4
- /**
5
- * Represents the props of the [KendoReact Dialog component]({% slug overview_dialog %}).
6
- */
7
- export interface DialogProps {
8
- /**
9
- * Focus the Dialog container automatically when mounted. By default the autoFocus is false.
10
- */
11
- autoFocus?: boolean;
12
- /**
13
- * Sets the title of the Dialog ([see example]({% slug title_dialog %})). If `title` is not specified, the Dialog does not render a **Close** button.
14
- */
15
- title?: string | React.ReactElement<any>;
16
- /**
17
- * Sets a class of the Dialog DOM element.
18
- */
19
- className?: string;
20
- /**
21
- * Specifies whether a close button should be rendered at the top corner of the dialog.
22
- */
23
- closeIcon?: boolean;
24
- /**
25
- * Specifies the width of the Dialog ([see example]({% slug dimensions_dialog %})).
26
- */
27
- width?: number | string;
28
- /**
29
- * Specifies the height of the Dialog ([see example]({% slug dimensions_dialog %})).
30
- */
31
- height?: number | string;
32
- /**
33
- * Specifies the minimum width of the Dialog.
34
- */
35
- minWidth?: number | string;
36
- /**
37
- * Fires when the **Close** button in the title is clicked or when the `Esc` button is pressed.
38
- */
39
- onClose?: (event: DialogCloseEvent) => void;
40
- /**
41
- * @hidden
42
- */
43
- children?: React.ReactNode;
44
- /**
45
- * Sets the `aria-labelledby` value.
46
- */
47
- id?: string;
48
- /**
49
- * Represents the `dir` HTML attribute.
50
- */
51
- dir?: string;
52
- /**
53
- * The styles that are applied to the Dialog.
54
- */
55
- style?: React.CSSProperties;
56
- /**
57
- * The styles that are applied to the content of the Dialog.
58
- */
59
- contentStyle?: React.CSSProperties;
60
- /**
61
- * Defines the container to which the Window will be appended. Defaults to its parent element.
62
- */
63
- appendTo?: any;
3
+ import { DialogProps } from './DialogProps';
4
+ interface DialogState {
5
+ zIndex: number;
64
6
  }
65
- export declare class Dialog extends React.Component<DialogProps> {
7
+ export declare class Dialog extends React.Component<DialogProps, DialogState> {
66
8
  /**
67
9
  * @hidden
68
10
  */
@@ -86,7 +28,12 @@ export declare class Dialog extends React.Component<DialogProps> {
86
28
  /**
87
29
  * @hidden
88
30
  */
89
- DialogRef: React.RefObject<HTMLDivElement>;
31
+ static contextType: React.Context<number>;
32
+ /**
33
+ * @hidden
34
+ */
35
+ element?: HTMLDivElement | null;
36
+ private _id;
90
37
  private titleId;
91
38
  constructor(props: DialogProps);
92
39
  /**
@@ -96,10 +43,19 @@ export declare class Dialog extends React.Component<DialogProps> {
96
43
  /**
97
44
  * @hidden
98
45
  */
99
- render(): JSX.Element;
100
- private handleCloseDialog;
101
- private handleKeyDown;
46
+ onCloseDialog: (event: React.SyntheticEvent<any, Event>) => void;
47
+ /**
48
+ * @hidden
49
+ */
50
+ onKeyDown: (event: any) => void;
51
+ /**
52
+ * @hidden
53
+ */
54
+ render(): React.ReactPortal;
102
55
  private getActionBar;
103
56
  private getContent;
104
57
  private generateTitleId;
58
+ private getCurrentZIndex;
59
+ private getDocument;
105
60
  }
61
+ export {};