@progress/kendo-react-popup 4.14.0-dev.202201140931 → 4.14.1-dev.202201181415
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/dist/cdn/js/kendo-react-popup.js +1 -1
- package/dist/es/Popup.d.ts +16 -157
- package/dist/es/Popup.js +20 -380
- package/dist/es/PopupWithoutContext.d.ts +174 -0
- package/dist/es/PopupWithoutContext.js +449 -0
- package/dist/es/animation.d.ts +1 -1
- package/dist/es/main.d.ts +5 -3
- package/dist/es/main.js +1 -1
- package/dist/es/models/CollisionType.d.ts +3 -1
- package/dist/es/models/Events.d.ts +17 -0
- package/dist/es/models/PopupProps.d.ts +91 -1
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/util.d.ts +0 -7
- package/dist/es/util.js +0 -7
- package/dist/npm/Popup.d.ts +16 -157
- package/dist/npm/Popup.js +20 -380
- package/dist/npm/PopupWithoutContext.d.ts +174 -0
- package/dist/npm/PopupWithoutContext.js +451 -0
- package/dist/npm/animation.d.ts +1 -1
- package/dist/npm/main.d.ts +5 -3
- package/dist/npm/main.js +3 -3
- package/dist/npm/models/CollisionType.d.ts +3 -1
- package/dist/npm/models/Events.d.ts +17 -0
- package/dist/npm/models/PopupProps.d.ts +91 -1
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/util.d.ts +0 -7
- package/dist/npm/util.js +0 -7
- package/dist/systemjs/kendo-react-popup.js +1 -1
- package/package.json +2 -2
- package/dist/es/PopupWithContext.d.ts +0 -19
- package/dist/es/PopupWithContext.js +0 -33
- package/dist/npm/PopupWithContext.d.ts +0 -19
- package/dist/npm/PopupWithContext.js +0 -35
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import { Offset } from './models/Offset';
|
|
4
|
+
import { PopupProps } from './models/PopupProps';
|
|
5
|
+
import { Align } from './models/Align';
|
|
6
|
+
import { Collision } from './models/Collision';
|
|
7
|
+
declare enum Status {
|
|
8
|
+
hiding = "hiding",
|
|
9
|
+
hidden = "hidden",
|
|
10
|
+
showing = "showing",
|
|
11
|
+
shown = "shown",
|
|
12
|
+
reposition = "reposition"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
export interface PopupState {
|
|
18
|
+
current: Status;
|
|
19
|
+
previous: Status;
|
|
20
|
+
props: {
|
|
21
|
+
show?: boolean;
|
|
22
|
+
anchor?: HTMLElement;
|
|
23
|
+
anchorAlign?: Align;
|
|
24
|
+
appendTo?: HTMLElement;
|
|
25
|
+
collision?: Collision;
|
|
26
|
+
popupAlign?: Align;
|
|
27
|
+
className?: string | Array<string>;
|
|
28
|
+
popupClass?: string | Array<string>;
|
|
29
|
+
style?: React.CSSProperties;
|
|
30
|
+
offset?: Offset;
|
|
31
|
+
contentKey?: any;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
37
|
+
export declare class PopupWithoutContext extends React.Component<PopupProps, PopupState> {
|
|
38
|
+
/**
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
static propTypes: {
|
|
42
|
+
anchor: (props: PopupProps) => Error;
|
|
43
|
+
appendTo: (props: PopupProps) => Error;
|
|
44
|
+
className: PropTypes.Requireable<string | object>;
|
|
45
|
+
id: PropTypes.Requireable<string>;
|
|
46
|
+
popupClass: PropTypes.Requireable<string | object>;
|
|
47
|
+
collision: PropTypes.Requireable<PropTypes.InferProps<{
|
|
48
|
+
horizontal: PropTypes.Requireable<string>;
|
|
49
|
+
vertical: PropTypes.Requireable<string>;
|
|
50
|
+
}>>;
|
|
51
|
+
anchorAlign: PropTypes.Requireable<PropTypes.InferProps<{
|
|
52
|
+
horizontal: PropTypes.Requireable<string>;
|
|
53
|
+
vertical: PropTypes.Requireable<string>;
|
|
54
|
+
}>>;
|
|
55
|
+
popupAlign: PropTypes.Requireable<PropTypes.InferProps<{
|
|
56
|
+
horizontal: PropTypes.Requireable<string>;
|
|
57
|
+
vertical: PropTypes.Requireable<string>;
|
|
58
|
+
}>>;
|
|
59
|
+
offset: PropTypes.Requireable<PropTypes.InferProps<{
|
|
60
|
+
left: PropTypes.Requireable<number>;
|
|
61
|
+
top: PropTypes.Requireable<number>;
|
|
62
|
+
}>>;
|
|
63
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
64
|
+
show: PropTypes.Requireable<boolean>;
|
|
65
|
+
animate: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
66
|
+
openDuration: PropTypes.Requireable<number>;
|
|
67
|
+
closeDuration: PropTypes.Requireable<number>;
|
|
68
|
+
}>>;
|
|
69
|
+
margin: PropTypes.Requireable<PropTypes.InferProps<{
|
|
70
|
+
horizontal: PropTypes.Requireable<number>;
|
|
71
|
+
vertical: PropTypes.Requireable<number>;
|
|
72
|
+
}>>;
|
|
73
|
+
positionMode: PropTypes.Requireable<string>;
|
|
74
|
+
scale: PropTypes.Requireable<number>;
|
|
75
|
+
style: PropTypes.Requireable<object>;
|
|
76
|
+
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
77
|
+
onPosition: PropTypes.Requireable<(...args: any[]) => any>;
|
|
78
|
+
onOpen: PropTypes.Requireable<(...args: any[]) => any>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* @hidden
|
|
82
|
+
*/
|
|
83
|
+
static defaultProps: {
|
|
84
|
+
collision: {
|
|
85
|
+
horizontal: string;
|
|
86
|
+
vertical: string;
|
|
87
|
+
};
|
|
88
|
+
anchorAlign: {
|
|
89
|
+
horizontal: string;
|
|
90
|
+
vertical: string;
|
|
91
|
+
};
|
|
92
|
+
popupAlign: {
|
|
93
|
+
horizontal: string;
|
|
94
|
+
vertical: string;
|
|
95
|
+
};
|
|
96
|
+
offset: {
|
|
97
|
+
left: number;
|
|
98
|
+
top: number;
|
|
99
|
+
};
|
|
100
|
+
animate: boolean;
|
|
101
|
+
show: boolean;
|
|
102
|
+
margin: {
|
|
103
|
+
horizontal: number;
|
|
104
|
+
vertical: number;
|
|
105
|
+
};
|
|
106
|
+
positionMode: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* @hidden
|
|
110
|
+
*/
|
|
111
|
+
static contextType: React.Context<number>;
|
|
112
|
+
/**
|
|
113
|
+
* @hidden
|
|
114
|
+
*/
|
|
115
|
+
static displayName: string;
|
|
116
|
+
/**
|
|
117
|
+
* @hidden
|
|
118
|
+
*/
|
|
119
|
+
readonly state: PopupState;
|
|
120
|
+
private _collisions;
|
|
121
|
+
private _scrollableParents;
|
|
122
|
+
private _popup;
|
|
123
|
+
constructor(props: PopupProps);
|
|
124
|
+
/**
|
|
125
|
+
* @hidden
|
|
126
|
+
*/
|
|
127
|
+
static getDerivedStateFromProps(props: PopupProps, state: PopupState): {
|
|
128
|
+
props: {
|
|
129
|
+
show: boolean;
|
|
130
|
+
anchor: HTMLElement;
|
|
131
|
+
anchorAlign: Align;
|
|
132
|
+
appendTo: HTMLElement;
|
|
133
|
+
collision: Collision;
|
|
134
|
+
popupAlign: Align;
|
|
135
|
+
className: string | string[];
|
|
136
|
+
popupClass: string | string[] | {
|
|
137
|
+
[key: string]: boolean;
|
|
138
|
+
};
|
|
139
|
+
style: React.CSSProperties;
|
|
140
|
+
offset: Offset;
|
|
141
|
+
contentKey: any;
|
|
142
|
+
};
|
|
143
|
+
current: Status;
|
|
144
|
+
previous: Status;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* @hidden
|
|
148
|
+
*/
|
|
149
|
+
componentDidUpdate(prevProps: PopupProps): void;
|
|
150
|
+
/**
|
|
151
|
+
* @hidden
|
|
152
|
+
*/
|
|
153
|
+
componentDidMount(): void;
|
|
154
|
+
/**
|
|
155
|
+
* @hidden
|
|
156
|
+
*/
|
|
157
|
+
componentWillUnmount(): void;
|
|
158
|
+
/**
|
|
159
|
+
* @hidden
|
|
160
|
+
*/
|
|
161
|
+
render(): React.ReactPortal;
|
|
162
|
+
private show;
|
|
163
|
+
private setPosition;
|
|
164
|
+
private onOpened;
|
|
165
|
+
private animate;
|
|
166
|
+
private onClosing;
|
|
167
|
+
private onClosed;
|
|
168
|
+
private readonly animationDuration;
|
|
169
|
+
private attachRepositionHandlers;
|
|
170
|
+
private detachRepositionHandlers;
|
|
171
|
+
private reposition;
|
|
172
|
+
private getCurrentZIndex;
|
|
173
|
+
}
|
|
174
|
+
export {};
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
var React = require("react");
|
|
28
|
+
var ReactDOM = require("react-dom");
|
|
29
|
+
var PropTypes = require("prop-types");
|
|
30
|
+
var animation_1 = require("./animation");
|
|
31
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
32
|
+
var kendo_popup_common_1 = require("@progress/kendo-popup-common");
|
|
33
|
+
var util_1 = require("./util");
|
|
34
|
+
var package_metadata_1 = require("./package-metadata");
|
|
35
|
+
var DEFAULT_POPUP_ZINDEX = 100;
|
|
36
|
+
var ZINDEX_POPUP_STEP = 1;
|
|
37
|
+
function isEquivalent(a, b) {
|
|
38
|
+
if (a === b) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (!!a !== !!b) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
var aProps = Object.getOwnPropertyNames(a);
|
|
45
|
+
var bProps = Object.getOwnPropertyNames(b);
|
|
46
|
+
if (aProps.length !== bProps.length) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
for (var i = 0; i < aProps.length; i++) {
|
|
50
|
+
var propName = aProps[i];
|
|
51
|
+
if (a[propName] !== b[propName]) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
var DEFAULT_OFFSET = {
|
|
58
|
+
left: -1000,
|
|
59
|
+
top: 0
|
|
60
|
+
};
|
|
61
|
+
var Status;
|
|
62
|
+
(function (Status) {
|
|
63
|
+
Status["hiding"] = "hiding";
|
|
64
|
+
Status["hidden"] = "hidden";
|
|
65
|
+
Status["showing"] = "showing";
|
|
66
|
+
Status["shown"] = "shown";
|
|
67
|
+
Status["reposition"] = "reposition";
|
|
68
|
+
})(Status || (Status = {}));
|
|
69
|
+
var ANIMATION_CONTAINER = 'k-animation-container';
|
|
70
|
+
var ANIMATION_CONTAINER_SHOWN = 'k-animation-container-shown';
|
|
71
|
+
var ANIMATION_CONTAINER_RELATIVE = 'k-animation-container-relative';
|
|
72
|
+
var ANIMATION_CONTAINER_CHILD = 'k-child-animation-container';
|
|
73
|
+
var K_POPUP = 'k-popup';
|
|
74
|
+
/**
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
|
+
var PopupWithoutContext = /** @class */ (function (_super) {
|
|
78
|
+
__extends(PopupWithoutContext, _super);
|
|
79
|
+
function PopupWithoutContext(props) {
|
|
80
|
+
var _this = _super.call(this, props) || this;
|
|
81
|
+
/**
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
_this.state = { current: Status.hidden, previous: Status.hidden, props: {} };
|
|
85
|
+
_this._popup = null;
|
|
86
|
+
_this.show = function (popup) {
|
|
87
|
+
_this.setPosition(popup);
|
|
88
|
+
_this.animate(popup.firstChild, 'enter', _this.onOpened);
|
|
89
|
+
_this.setState({ current: Status.shown, previous: _this.state.current });
|
|
90
|
+
};
|
|
91
|
+
_this.setPosition = function (popup) {
|
|
92
|
+
var _a = _this.props, anchorAlign = _a.anchorAlign, popupAlign = _a.popupAlign, collision = _a.collision, offset = _a.offset, anchor = _a.anchor, margin = _a.margin, scale = _a.scale, positionMode = _a.positionMode;
|
|
93
|
+
var alignedOffset = kendo_popup_common_1.alignElement({
|
|
94
|
+
anchor: anchor,
|
|
95
|
+
anchorAlign: anchorAlign,
|
|
96
|
+
element: popup,
|
|
97
|
+
elementAlign: popupAlign,
|
|
98
|
+
offset: offset,
|
|
99
|
+
margin: margin,
|
|
100
|
+
positionMode: positionMode,
|
|
101
|
+
scale: scale
|
|
102
|
+
});
|
|
103
|
+
var position = kendo_popup_common_1.positionElement({
|
|
104
|
+
anchor: anchor,
|
|
105
|
+
anchorAlign: anchorAlign,
|
|
106
|
+
element: popup,
|
|
107
|
+
elementAlign: popupAlign,
|
|
108
|
+
collisions: collision,
|
|
109
|
+
currentLocation: alignedOffset,
|
|
110
|
+
margin: _this.props.margin
|
|
111
|
+
});
|
|
112
|
+
popup.style.top = position.offset.top + 'px';
|
|
113
|
+
popup.style.left = position.offset.left + 'px';
|
|
114
|
+
_this._collisions = {
|
|
115
|
+
fit: position.fit,
|
|
116
|
+
fitted: position.fitted,
|
|
117
|
+
flip: position.flip,
|
|
118
|
+
flipped: position.flipped
|
|
119
|
+
};
|
|
120
|
+
if (_this.props.onPosition) {
|
|
121
|
+
var event_1 = {
|
|
122
|
+
target: _this,
|
|
123
|
+
flipped: position.flipped,
|
|
124
|
+
fitted: position.fitted
|
|
125
|
+
};
|
|
126
|
+
_this.props.onPosition.call(undefined, event_1);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
_this.onOpened = function () {
|
|
130
|
+
var element = _this._popup;
|
|
131
|
+
if (!element) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (_this.props.show) {
|
|
135
|
+
element.classList.add(ANIMATION_CONTAINER_SHOWN);
|
|
136
|
+
}
|
|
137
|
+
_this.attachRepositionHandlers(element);
|
|
138
|
+
if (_this.props.onOpen) {
|
|
139
|
+
_this.props.onOpen.call(undefined, { target: _this });
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
_this.animate = function (element, type, callback) {
|
|
143
|
+
if (!_this.props.popupAlign) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
var animationDirection;
|
|
147
|
+
var _a = _this.props.popupAlign, horizontal = _a.horizontal, vertical = _a.vertical;
|
|
148
|
+
if (horizontal === 'left' && vertical === 'center') {
|
|
149
|
+
animationDirection = 'right';
|
|
150
|
+
}
|
|
151
|
+
else if (horizontal === 'right' && vertical === 'center') {
|
|
152
|
+
animationDirection = 'left';
|
|
153
|
+
}
|
|
154
|
+
else if (vertical === 'top') {
|
|
155
|
+
animationDirection = 'down';
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
animationDirection = 'up';
|
|
159
|
+
}
|
|
160
|
+
var flipPositions = {
|
|
161
|
+
down: 'up',
|
|
162
|
+
up: 'down',
|
|
163
|
+
left: 'right',
|
|
164
|
+
right: 'left'
|
|
165
|
+
};
|
|
166
|
+
if (_this._collisions && _this._collisions.flipped) {
|
|
167
|
+
animationDirection = flipPositions[animationDirection];
|
|
168
|
+
}
|
|
169
|
+
animation_1.slide(element, animationDirection, _this.animationDuration[type], type, callback);
|
|
170
|
+
};
|
|
171
|
+
_this.onClosing = function (popup) {
|
|
172
|
+
if (!_this.props.show) {
|
|
173
|
+
popup.classList.remove(ANIMATION_CONTAINER_SHOWN);
|
|
174
|
+
}
|
|
175
|
+
_this.detachRepositionHandlers();
|
|
176
|
+
};
|
|
177
|
+
_this.onClosed = function () {
|
|
178
|
+
if (_this.state.current === Status.hiding && _this.state.previous === Status.shown) {
|
|
179
|
+
_this.setState({ current: Status.hidden, previous: _this.state.current });
|
|
180
|
+
}
|
|
181
|
+
if (_this.props.onClose) {
|
|
182
|
+
_this.props.onClose.call(undefined, { target: _this });
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
_this.getCurrentZIndex = function () {
|
|
186
|
+
return _this.context ? _this.context + ZINDEX_POPUP_STEP : DEFAULT_POPUP_ZINDEX;
|
|
187
|
+
};
|
|
188
|
+
kendo_react_common_1.validatePackage(package_metadata_1.packageMetadata);
|
|
189
|
+
_this.reposition = util_1.throttle(_this.reposition.bind(_this), util_1.FRAME_DURATION);
|
|
190
|
+
return _this;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @hidden
|
|
194
|
+
*/
|
|
195
|
+
PopupWithoutContext.getDerivedStateFromProps = function (props, state) {
|
|
196
|
+
var show = props.show, anchor = props.anchor, anchorAlign = props.anchorAlign, appendTo = props.appendTo, collision = props.collision, popupAlign = props.popupAlign, className = props.className, popupClass = props.popupClass, style = props.style, offset = props.offset, contentKey = props.contentKey;
|
|
197
|
+
var nextState = __assign({}, state, { props: {
|
|
198
|
+
show: show, anchor: anchor, anchorAlign: anchorAlign, appendTo: appendTo, collision: collision, popupAlign: popupAlign, className: className, popupClass: popupClass, style: style, offset: offset, contentKey: contentKey
|
|
199
|
+
} });
|
|
200
|
+
if (props.show) {
|
|
201
|
+
if (state.current === Status.hidden || state.current === Status.hiding) {
|
|
202
|
+
return __assign({}, nextState, { current: Status.showing, previous: state.current });
|
|
203
|
+
}
|
|
204
|
+
if (state.current === Status.showing) {
|
|
205
|
+
return __assign({}, nextState, { current: Status.shown, previous: state.current });
|
|
206
|
+
}
|
|
207
|
+
if (state.current === Status.shown &&
|
|
208
|
+
(!isEquivalent(offset, state.props.offset) ||
|
|
209
|
+
!isEquivalent(anchorAlign, state.props.anchorAlign) ||
|
|
210
|
+
!isEquivalent(appendTo, state.props.appendTo) ||
|
|
211
|
+
!isEquivalent(collision, state.props.collision) ||
|
|
212
|
+
!isEquivalent(popupAlign, state.props.popupAlign) ||
|
|
213
|
+
!isEquivalent(style, state.props.style) ||
|
|
214
|
+
anchor !== state.props.anchor ||
|
|
215
|
+
popupClass !== state.props.popupClass ||
|
|
216
|
+
className !== state.props.className)) {
|
|
217
|
+
return __assign({}, nextState, { current: Status.reposition, previous: state.current });
|
|
218
|
+
}
|
|
219
|
+
return nextState;
|
|
220
|
+
}
|
|
221
|
+
if (state.current === Status.hiding || state.current === Status.hidden) {
|
|
222
|
+
return __assign({}, nextState, { current: Status.hidden, previous: state.current });
|
|
223
|
+
}
|
|
224
|
+
return __assign({}, nextState, { current: Status.hiding, previous: state.current });
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* @hidden
|
|
228
|
+
*/
|
|
229
|
+
PopupWithoutContext.prototype.componentDidUpdate = function (prevProps) {
|
|
230
|
+
if (this.state.current === Status.showing && this._popup) {
|
|
231
|
+
this.show(this._popup);
|
|
232
|
+
}
|
|
233
|
+
else if (this.state.current === Status.hiding && this._popup) {
|
|
234
|
+
this.onClosing(this._popup);
|
|
235
|
+
this.animate(this._popup.firstChild, 'exit', this.onClosed);
|
|
236
|
+
}
|
|
237
|
+
else if (this.state.current === Status.reposition && this.state.previous === Status.shown) {
|
|
238
|
+
this.setState({ current: Status.shown, previous: this.state.current });
|
|
239
|
+
}
|
|
240
|
+
else if (this.state.current === Status.shown &&
|
|
241
|
+
prevProps.contentKey !== this.props.contentKey && this._popup) {
|
|
242
|
+
this.setPosition(this._popup);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* @hidden
|
|
247
|
+
*/
|
|
248
|
+
PopupWithoutContext.prototype.componentDidMount = function () {
|
|
249
|
+
if (this.state.current === Status.showing && this._popup) {
|
|
250
|
+
this.show(this._popup);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* @hidden
|
|
255
|
+
*/
|
|
256
|
+
PopupWithoutContext.prototype.componentWillUnmount = function () {
|
|
257
|
+
this.detachRepositionHandlers();
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* @hidden
|
|
261
|
+
*/
|
|
262
|
+
PopupWithoutContext.prototype.render = function () {
|
|
263
|
+
var _this = this;
|
|
264
|
+
var _a = this.props, children = _a.children, className = _a.className, popupClass = _a.popupClass, show = _a.show, id = _a.id, positionMode = _a.positionMode;
|
|
265
|
+
var appendTo = this.props.appendTo ?
|
|
266
|
+
this.props.appendTo :
|
|
267
|
+
kendo_react_common_1.canUseDOM ?
|
|
268
|
+
(this.props.anchor && this.props.anchor.ownerDocument ? this.props.anchor.ownerDocument.body : document.body)
|
|
269
|
+
: undefined;
|
|
270
|
+
if (this.state.current === Status.reposition && this.state.previous === Status.shown && this._popup) {
|
|
271
|
+
this.setPosition(this._popup);
|
|
272
|
+
}
|
|
273
|
+
var style = Object.assign({}, { position: positionMode, top: 0, left: -10000 }, this.props.style || {});
|
|
274
|
+
var closing = this.state.current === Status.hiding;
|
|
275
|
+
if ((show || closing) && appendTo) {
|
|
276
|
+
var currentZIndex = this.getCurrentZIndex();
|
|
277
|
+
var popupElement = (React.createElement(kendo_react_common_1.ZIndexContext.Provider, { value: currentZIndex },
|
|
278
|
+
React.createElement("div", { className: kendo_react_common_1.classNames(ANIMATION_CONTAINER, ANIMATION_CONTAINER_RELATIVE, className), id: id, ref: function (e) { return _this._popup = e; }, style: __assign({ zIndex: currentZIndex }, style) },
|
|
279
|
+
React.createElement("div", { className: kendo_react_common_1.classNames(K_POPUP, popupClass, ANIMATION_CONTAINER_CHILD), style: { transitionDelay: '0ms' } }, children))));
|
|
280
|
+
return ReactDOM.createPortal(popupElement, appendTo);
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
};
|
|
284
|
+
Object.defineProperty(PopupWithoutContext.prototype, "animationDuration", {
|
|
285
|
+
get: function () {
|
|
286
|
+
var animate = this.props.animate;
|
|
287
|
+
var enter = 0;
|
|
288
|
+
var exit = 0;
|
|
289
|
+
if (animate) {
|
|
290
|
+
if (animate === true) {
|
|
291
|
+
enter = exit = 300;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
enter = animate.openDuration || 0;
|
|
295
|
+
exit = animate.closeDuration || 0;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return { enter: enter, exit: exit };
|
|
299
|
+
},
|
|
300
|
+
enumerable: true,
|
|
301
|
+
configurable: true
|
|
302
|
+
});
|
|
303
|
+
PopupWithoutContext.prototype.attachRepositionHandlers = function (element) {
|
|
304
|
+
var _this = this;
|
|
305
|
+
this.detachRepositionHandlers();
|
|
306
|
+
this._scrollableParents = kendo_popup_common_1.domUtils.scrollableParents(this.props.anchor || element);
|
|
307
|
+
this._scrollableParents.map(function (p) { return p.addEventListener('scroll', _this.reposition); });
|
|
308
|
+
window.addEventListener('resize', this.reposition);
|
|
309
|
+
};
|
|
310
|
+
PopupWithoutContext.prototype.detachRepositionHandlers = function () {
|
|
311
|
+
var _this = this;
|
|
312
|
+
if (this._scrollableParents) {
|
|
313
|
+
this._scrollableParents.map(function (p) { return p.removeEventListener('scroll', _this.reposition); });
|
|
314
|
+
this._scrollableParents = undefined;
|
|
315
|
+
}
|
|
316
|
+
window.removeEventListener('resize', this.reposition);
|
|
317
|
+
};
|
|
318
|
+
PopupWithoutContext.prototype.reposition = function () {
|
|
319
|
+
this.setState({ current: Status.reposition, previous: this.state.current });
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* @hidden
|
|
323
|
+
*/
|
|
324
|
+
PopupWithoutContext.propTypes = {
|
|
325
|
+
anchor: function (props) {
|
|
326
|
+
var anchor = props.anchor;
|
|
327
|
+
if (anchor && typeof anchor.nodeType !== 'number') {
|
|
328
|
+
return new Error('Invalid prop `anchor` supplied to `Kendo React Popup`. Validation failed.');
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
},
|
|
332
|
+
appendTo: function (props) {
|
|
333
|
+
var element = props.appendTo;
|
|
334
|
+
if (element && typeof element.nodeType !== 'number') {
|
|
335
|
+
return new Error('Invalid prop `appendTo` supplied to `Kendo React Popup`. Validation failed.');
|
|
336
|
+
}
|
|
337
|
+
return null;
|
|
338
|
+
},
|
|
339
|
+
className: PropTypes.oneOfType([
|
|
340
|
+
PropTypes.string,
|
|
341
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
342
|
+
PropTypes.object
|
|
343
|
+
]),
|
|
344
|
+
id: PropTypes.string,
|
|
345
|
+
popupClass: PropTypes.oneOfType([
|
|
346
|
+
PropTypes.string,
|
|
347
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
348
|
+
PropTypes.object
|
|
349
|
+
]),
|
|
350
|
+
collision: PropTypes.shape({
|
|
351
|
+
horizontal: PropTypes.oneOf([
|
|
352
|
+
kendo_popup_common_1.Collision.fit,
|
|
353
|
+
kendo_popup_common_1.Collision.flip,
|
|
354
|
+
kendo_popup_common_1.Collision.none
|
|
355
|
+
]),
|
|
356
|
+
vertical: PropTypes.oneOf([
|
|
357
|
+
kendo_popup_common_1.Collision.fit,
|
|
358
|
+
kendo_popup_common_1.Collision.flip,
|
|
359
|
+
kendo_popup_common_1.Collision.none
|
|
360
|
+
])
|
|
361
|
+
}),
|
|
362
|
+
anchorAlign: PropTypes.shape({
|
|
363
|
+
horizontal: PropTypes.oneOf([
|
|
364
|
+
kendo_popup_common_1.AlignPoint.left,
|
|
365
|
+
kendo_popup_common_1.AlignPoint.center,
|
|
366
|
+
kendo_popup_common_1.AlignPoint.right
|
|
367
|
+
]),
|
|
368
|
+
vertical: PropTypes.oneOf([
|
|
369
|
+
kendo_popup_common_1.AlignPoint.top,
|
|
370
|
+
kendo_popup_common_1.AlignPoint.center,
|
|
371
|
+
kendo_popup_common_1.AlignPoint.bottom
|
|
372
|
+
])
|
|
373
|
+
}),
|
|
374
|
+
popupAlign: PropTypes.shape({
|
|
375
|
+
horizontal: PropTypes.oneOf([
|
|
376
|
+
kendo_popup_common_1.AlignPoint.left,
|
|
377
|
+
kendo_popup_common_1.AlignPoint.center,
|
|
378
|
+
kendo_popup_common_1.AlignPoint.right
|
|
379
|
+
]),
|
|
380
|
+
vertical: PropTypes.oneOf([
|
|
381
|
+
kendo_popup_common_1.AlignPoint.top,
|
|
382
|
+
kendo_popup_common_1.AlignPoint.center,
|
|
383
|
+
kendo_popup_common_1.AlignPoint.bottom
|
|
384
|
+
])
|
|
385
|
+
}),
|
|
386
|
+
offset: PropTypes.shape({
|
|
387
|
+
left: PropTypes.number,
|
|
388
|
+
top: PropTypes.number
|
|
389
|
+
}),
|
|
390
|
+
children: PropTypes.oneOfType([
|
|
391
|
+
PropTypes.element,
|
|
392
|
+
PropTypes.node
|
|
393
|
+
]),
|
|
394
|
+
show: PropTypes.bool,
|
|
395
|
+
animate: PropTypes.oneOfType([
|
|
396
|
+
PropTypes.bool,
|
|
397
|
+
PropTypes.shape({
|
|
398
|
+
openDuration: PropTypes.number,
|
|
399
|
+
closeDuration: PropTypes.number
|
|
400
|
+
})
|
|
401
|
+
]),
|
|
402
|
+
margin: PropTypes.shape({
|
|
403
|
+
horizontal: PropTypes.number,
|
|
404
|
+
vertical: PropTypes.number
|
|
405
|
+
}),
|
|
406
|
+
positionMode: PropTypes.oneOf([
|
|
407
|
+
'fixed',
|
|
408
|
+
'absolute'
|
|
409
|
+
]),
|
|
410
|
+
scale: PropTypes.number,
|
|
411
|
+
style: PropTypes.object,
|
|
412
|
+
onClose: PropTypes.func,
|
|
413
|
+
onPosition: PropTypes.func,
|
|
414
|
+
onOpen: PropTypes.func
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* @hidden
|
|
418
|
+
*/
|
|
419
|
+
PopupWithoutContext.defaultProps = {
|
|
420
|
+
collision: {
|
|
421
|
+
horizontal: kendo_popup_common_1.Collision.fit,
|
|
422
|
+
vertical: kendo_popup_common_1.Collision.flip
|
|
423
|
+
},
|
|
424
|
+
anchorAlign: {
|
|
425
|
+
horizontal: kendo_popup_common_1.AlignPoint.left,
|
|
426
|
+
vertical: kendo_popup_common_1.AlignPoint.bottom
|
|
427
|
+
},
|
|
428
|
+
popupAlign: {
|
|
429
|
+
horizontal: kendo_popup_common_1.AlignPoint.left,
|
|
430
|
+
vertical: kendo_popup_common_1.AlignPoint.top
|
|
431
|
+
},
|
|
432
|
+
offset: DEFAULT_OFFSET,
|
|
433
|
+
animate: true,
|
|
434
|
+
show: false,
|
|
435
|
+
margin: {
|
|
436
|
+
horizontal: 0,
|
|
437
|
+
vertical: 0
|
|
438
|
+
},
|
|
439
|
+
positionMode: 'absolute'
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* @hidden
|
|
443
|
+
*/
|
|
444
|
+
PopupWithoutContext.contextType = kendo_react_common_1.ZIndexContext;
|
|
445
|
+
/**
|
|
446
|
+
* @hidden
|
|
447
|
+
*/
|
|
448
|
+
PopupWithoutContext.displayName = 'PopupComponent';
|
|
449
|
+
return PopupWithoutContext;
|
|
450
|
+
}(React.Component));
|
|
451
|
+
exports.PopupWithoutContext = PopupWithoutContext;
|
package/dist/npm/animation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @hidden
|
|
3
3
|
*/
|
|
4
|
-
export declare const slide: (element: HTMLElement, direction:
|
|
4
|
+
export declare const slide: (element: HTMLElement, direction: NavigationReason, duration: number, type: "enter" | "exit", callback: any) => any;
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { Popup, PopupPropsContext } from './
|
|
1
|
+
import { Popup, PopupPropsContext } from './Popup';
|
|
2
2
|
import { PopupProps } from './models/PopupProps';
|
|
3
|
-
import { PopupSettings } from './models/PopupSettings';
|
|
4
3
|
import { Align } from './models/Align';
|
|
5
4
|
import { Collision } from './models/Collision';
|
|
6
5
|
import { Offset } from './models/Offset';
|
|
7
6
|
import { PopupAnimation } from './models/PopupAnimation';
|
|
8
7
|
import { OpenEvent as PopupOpenEvent, CloseEvent as PopupCloseEvent } from './models/Events';
|
|
9
|
-
|
|
8
|
+
import { Margin } from './models/Margin';
|
|
9
|
+
import { CollisionType } from './models/CollisionType';
|
|
10
|
+
import { PositionMode } from './models/PositionMode';
|
|
11
|
+
export { Popup, PopupPropsContext, PopupProps, Align, Collision, Offset, PopupAnimation, Margin, PositionMode, CollisionType, PopupOpenEvent, PopupCloseEvent };
|
package/dist/npm/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var
|
|
4
|
-
exports.Popup =
|
|
5
|
-
exports.PopupPropsContext =
|
|
3
|
+
var Popup_1 = require("./Popup");
|
|
4
|
+
exports.Popup = Popup_1.Popup;
|
|
5
|
+
exports.PopupPropsContext = Popup_1.PopupPropsContext;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { CollisionType as CollisionTypeBase } from '@progress/kendo-popup-common';
|
|
1
2
|
/**
|
|
2
3
|
* Defines the possible collision behavior when the Popup is not fully visible.
|
|
3
4
|
*
|
|
4
5
|
* The available options are:
|
|
5
6
|
* - `fit`—Moves the Popup horizontally until it is fully displayed in the viewport.
|
|
6
7
|
* - `flip`—Flips the Popup position based on the origin and the position properties.
|
|
8
|
+
* - `none`—The Popup is rendered at its original position.
|
|
7
9
|
*/
|
|
8
|
-
export declare type CollisionType =
|
|
10
|
+
export declare type CollisionType = CollisionTypeBase;
|
|
@@ -17,3 +17,20 @@ export interface CloseEvent {
|
|
|
17
17
|
*/
|
|
18
18
|
target: Popup;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Represents the object of the `Position` Popup event.
|
|
22
|
+
*/
|
|
23
|
+
export interface PositionEvent {
|
|
24
|
+
/**
|
|
25
|
+
* An event target.
|
|
26
|
+
*/
|
|
27
|
+
target: Popup;
|
|
28
|
+
/**
|
|
29
|
+
* Indicates if the position is fitted.
|
|
30
|
+
*/
|
|
31
|
+
fitted: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Indicates if the position is flipped.
|
|
34
|
+
*/
|
|
35
|
+
flipped: boolean;
|
|
36
|
+
}
|