@progress/kendo-react-popup 9.0.0-develop.2 → 9.0.0-develop.21

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/Popup.js CHANGED
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),a=require("./PopupWithoutContext.js"),l=require("@progress/kendo-react-common");function i(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 r=i(s),c=r.createContext(e=>e),u=r.forwardRef((e,o)=>{const t=r.useContext(c),n=l.useUnstyled(),p=t.call(void 0,e);return r.createElement(a.PopupWithoutContext,{ref:o,unstyled:n,...p})});u.displayName="Popup";exports.Popup=u;exports.PopupPropsContext=c;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("react"),ve=require("react-dom"),n=require("prop-types"),ye=require("./animation.js"),a=require("@progress/kendo-react-common"),t=require("@progress/kendo-popup-common"),ee=require("./util.js"),Oe=require("./package-metadata.js");function ne(i){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const h in i)if(h!=="default"){const v=Object.getOwnPropertyDescriptor(i,h);Object.defineProperty(c,h,v.get?v:{enumerable:!0,get:()=>i[h]})}}return c.default=i,Object.freeze(c)}const l=ne(we),Ae=ne(ve),te=l.createContext(i=>i),Ce=100,be=1;function E(i,c){if(i===c)return!0;if(!!i!=!!c)return!1;const h=Object.getOwnPropertyNames(i),v=Object.getOwnPropertyNames(c);if(h.length!==v.length)return!1;for(let P=0;P<h.length;P++){const w=h[P];if(i[w]!==c[w])return!1}return!0}const Ee={left:-1e3,top:0},U=l.forwardRef((i,c)=>{const v=l.useContext(te).call(void 0,i);a.validatePackage(Oe.packageMetadata);const{collision:P=g.collision,anchorAlign:w=g.anchorAlign,popupAlign:y=g.popupAlign,offset:R=g.offset,animate:oe=g.animate,show:O=g.show,margin:K=g.margin,positionMode:Z=g.positionMode,appendTo:A,contentKey:T,anchor:f,scale:re,role:ie,onKeyDown:se,onPosition:F,onOpen:H,onMouseDownOutside:V,onClose:X,className:N,popupClass:M,id:le,style:z,children:ce}=v,ue=a.useUnstyled(),S=v.unstyled||ue,D=S&&S.uPopup,[o,k]=l.useState({current:"hidden",previous:"hidden",props:{}}),W=e=>{window==null||window.addEventListener("mousedown",G),I(e),B(e.firstChild,"enter",ae),k({...r,current:"shown",previous:r.current})},I=e=>{const{width:s,height:m}=e.style;e.style.width=e.offsetWidth+"px",e.style.height=e.offsetHeight+"px";const d=t.alignElement({anchor:f,anchorAlign:w,element:e,elementAlign:y,offset:R,margin:K,positionMode:Z,scale:re}),p=t.positionElement({anchor:f,anchorAlign:w,element:e,elementAlign:y,collisions:P,currentLocation:d,margin:K});if(e.style.top=p.offset.top+"px",e.style.left=p.offset.left+"px",e.style.width=s,e.style.height=m,j.current={fit:p.fit,fitted:p.fitted,flip:p.flip,flipped:p.flipped},F){const x={target:b.current,flipped:p.flipped,fitted:p.fitted};F.call(void 0,x)}},ae=()=>{const e=u.current;e&&(O&&e.classList.add(...a.classNames(a.uPopup.animationContainerShown({c:D})).split(" ").filter(s=>s)),de(e),H&&H.call(void 0,{target:b.current}))},B=(e,s,m)=>{if(!y)return;let d;const{horizontal:p,vertical:x}=y;p==="left"&&x==="center"?d="right":p==="right"&&x==="center"?d="left":x==="top"?d="down":d="up";const Pe={down:"up",up:"down",left:"right",right:"left"};j.current&&j.current.flipped&&(d=Pe[d]),ye.slide(e,d,fe()[s],s,m,D)},G=e=>{var d;const s=((d=e==null?void 0:e.target)==null?void 0:d.closest(".k-animation-container"))===null,m=(f==null?void 0:f.contains(e==null?void 0:e.target))||!1;if(s){if(V){const p={target:b.current,event:e,state:r,isAnchorClicked:m};V.call(void 0,p)}window==null||window.removeEventListener("mousedown",G)}},pe=e=>{if(!O){const s=S&&S.uPopup;e.classList.remove(...a.classNames(a.uPopup.animationContainerShown({c:s})).split(" ").filter(m=>m))}_()},J=()=>{r.current==="hiding"&&r.previous==="shown"&&k({...r,current:"hidden",previous:r.current}),X&&X.call(void 0,{target:b.current})},fe=()=>{const e=oe;let s=0,m=0;return e&&(e===!0?s=m=300:(s=e.openDuration||0,m=e.closeDuration||0)),{enter:s,exit:m}},de=e=>{_(),C.current=t.domUtils.scrollableParents(f||e),C.current&&C.current.map(s=>s.addEventListener("scroll",L)),window.addEventListener("resize",L)},_=()=>{C.current&&(C.current.map(e=>e.removeEventListener("scroll",L)),C.current=void 0),window.removeEventListener("resize",L)},L=ee.throttle(()=>{o.current!=="hidden"&&o.current!=="hiding"&&k({...o,current:"reposition",previous:o.current})},ee.FRAME_DURATION),me=()=>Q?Q+be:Ce,Q=a.useZIndexContext()||0,j=l.useRef(),C=l.useRef(),u=l.useRef(null),b=l.useRef(null),Y=l.useRef({}),q=l.useRef(!1);l.useImperativeHandle(b,()=>({element:u.current,setPosition:I,props:i})),l.useImperativeHandle(c,()=>b.current);const r=l.useMemo(()=>{const e={...o,props:{show:O,anchor:f,anchorAlign:w,appendTo:A,collision:P,popupAlign:y,className:N,popupClass:M,style:z,offset:R,contentKey:T}};return O?o.current==="hidden"||o.current==="hiding"?{...e,current:"showing",previous:o.current}:o.current==="showing"?{...e,current:"shown",previous:o.current}:o.current==="shown"&&(!E(R,o.props.offset)||!E(w,o.props.anchorAlign)||!E(A,o.props.appendTo)||!E(P,o.props.collision)||!E(y,o.props.popupAlign)||!E(z,o.props.style)||f!==o.props.anchor||M!==o.props.popupClass||N!==o.props.className)?{...e,current:"reposition",previous:o.current}:e:o.current==="hiding"||o.current==="hidden"?{...e,current:"hidden",previous:o.current}:{...e,current:"hiding",previous:o.current}},[O,f,w,A,P,y,N,M,z,R,T,o]);l.useEffect(()=>{r.current==="hiding"&&!q.current&&u.current?(q.current=!0,pe(u.current),B(u.current.firstChild,"exit",J)):(q.current=!1,r.current==="showing"&&u.current?W(u.current):r.current==="hiding"&&u.current?J():r.current==="reposition"&&r.previous==="shown"?setTimeout(()=>{k({...r,current:"shown",previous:r.current})},0):r.current==="shown"&&Y.current.contentKey!==T&&u.current&&I(u.current)),Y.current={contentKey:T}},[r]),l.useEffect(()=>(r.current==="showing"&&u.current&&W(u.current),()=>{_()}),[]);const $=A||(a.canUseDOM?f&&f.ownerDocument?f.ownerDocument.body:document.body:void 0);r.current==="reposition"&&r.previous==="shown"&&u.current&&I(u.current);const he=Object.assign({},{position:Z,top:0,left:-1e4},z||{}),ge=r.current==="hiding";if((O||ge)&&$){const e=me(),s=l.createElement(a.ZIndexContext.Provider,{value:e},l.createElement("div",{onKeyDown:se,className:a.classNames(a.uPopup.animationContainer({c:D}),N),id:le,ref:u,style:{zIndex:e,...he}},l.createElement("div",{className:a.classNames(a.uPopup.animationChild({c:D})),style:{transitionDelay:"0ms"}},l.createElement("div",{role:ie,className:a.classNames(a.uPopup.popup({c:D}),M)},ce))));return A!==null?Ae.createPortal(s,$):s}return null}),g={collision:{horizontal:t.Collision.fit,vertical:t.Collision.flip},anchorAlign:{horizontal:t.AlignPoint.left,vertical:t.AlignPoint.bottom},popupAlign:{horizontal:t.AlignPoint.left,vertical:t.AlignPoint.top},offset:Ee,animate:!0,show:!1,margin:{horizontal:0,vertical:0},positionMode:"absolute"};U.displayName="Popup";U.propTypes={anchor:function(i){const c=i.anchor;return c&&typeof c.nodeType!="number"?new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. Validation failed."):null},appendTo:function(i){const c=i.appendTo;return c&&typeof c.nodeType!="number"?new Error("Invalid prop `appendTo` supplied to `Kendo React Popup`. Validation failed."):null},className:n.oneOfType([n.string,n.arrayOf(n.string.isRequired)]),id:n.string,popupClass:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),collision:n.shape({horizontal:n.oneOf([t.Collision.fit,t.Collision.flip,t.Collision.none]),vertical:n.oneOf([t.Collision.fit,t.Collision.flip,t.Collision.none])}),anchorAlign:n.shape({horizontal:n.oneOf([t.AlignPoint.left,t.AlignPoint.center,t.AlignPoint.right]),vertical:n.oneOf([t.AlignPoint.top,t.AlignPoint.center,t.AlignPoint.bottom])}),popupAlign:n.shape({horizontal:n.oneOf([t.AlignPoint.left,t.AlignPoint.center,t.AlignPoint.right]),vertical:n.oneOf([t.AlignPoint.top,t.AlignPoint.center,t.AlignPoint.bottom])}),offset:n.shape({left:n.number,top:n.number}),children:n.oneOfType([n.element,n.node]),show:n.bool,animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),margin:n.shape({horizontal:n.number,vertical:n.number}),positionMode:n.oneOf(["fixed","absolute"]),scale:n.number,style:n.object,onClose:n.func,onPosition:n.func,onOpen:n.func,onKeyDown:n.func,onMouseDownOutside:n.func};exports.Popup=U;exports.PopupPropsContext=te;exports.popupDefaultProps=g;
package/Popup.mjs CHANGED
@@ -6,22 +6,305 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as t from "react";
10
- import { PopupWithoutContext as s } from "./PopupWithoutContext.mjs";
11
- import { useUnstyled as c } from "@progress/kendo-react-common";
12
- const u = t.createContext((o) => o), a = t.forwardRef((o, e) => {
13
- const p = t.useContext(u), r = c(), n = p.call(void 0, o);
14
- return /* @__PURE__ */ t.createElement(
15
- s,
16
- {
17
- ref: e,
18
- unstyled: r,
19
- ...n
9
+ import * as i from "react";
10
+ import * as we from "react-dom";
11
+ import t from "prop-types";
12
+ import { slide as ve } from "./animation.mjs";
13
+ import { validatePackage as ye, useUnstyled as Pe, useZIndexContext as Oe, canUseDOM as Ee, ZIndexContext as be, classNames as D, uPopup as A } from "@progress/kendo-react-common";
14
+ import { Collision as w, AlignPoint as s, alignElement as Ce, positionElement as xe, domUtils as De } from "@progress/kendo-popup-common";
15
+ import { throttle as Ae, FRAME_DURATION as Te } from "./util.mjs";
16
+ import { packageMetadata as Re } from "./package-metadata.mjs";
17
+ const Ne = i.createContext((l) => l), ze = 100, Ie = 1;
18
+ function b(l, u) {
19
+ if (l === u)
20
+ return !0;
21
+ if (!!l != !!u)
22
+ return !1;
23
+ const T = Object.getOwnPropertyNames(l), R = Object.getOwnPropertyNames(u);
24
+ if (T.length !== R.length)
25
+ return !1;
26
+ for (let m = 0; m < T.length; m++) {
27
+ const h = T[m];
28
+ if (l[h] !== u[h])
29
+ return !1;
30
+ }
31
+ return !0;
32
+ }
33
+ const Me = {
34
+ left: -1e3,
35
+ top: 0
36
+ }, te = i.forwardRef((l, u) => {
37
+ const R = i.useContext(Ne).call(void 0, l);
38
+ ye(Re);
39
+ const {
40
+ collision: m = g.collision,
41
+ anchorAlign: h = g.anchorAlign,
42
+ popupAlign: v = g.popupAlign,
43
+ offset: N = g.offset,
44
+ animate: ne = g.animate,
45
+ show: y = g.show,
46
+ margin: F = g.margin,
47
+ positionMode: H = g.positionMode,
48
+ appendTo: P,
49
+ contentKey: z,
50
+ anchor: p,
51
+ scale: oe,
52
+ role: re,
53
+ onKeyDown: ie,
54
+ onPosition: q,
55
+ onOpen: V,
56
+ onMouseDownOutside: X,
57
+ onClose: W,
58
+ className: I,
59
+ popupClass: M,
60
+ id: se,
61
+ style: L,
62
+ children: ce
63
+ } = R, le = Pe(), S = R.unstyled || le, C = S && S.uPopup, [n, U] = i.useState({
64
+ current: "hidden",
65
+ previous: "hidden",
66
+ props: {}
67
+ }), B = (e) => {
68
+ window == null || window.addEventListener("mousedown", J), k(e), G(e.firstChild, "enter", ae), U({ ...o, current: "shown", previous: o.current });
69
+ }, k = (e) => {
70
+ const { width: r, height: d } = e.style;
71
+ e.style.width = e.offsetWidth + "px", e.style.height = e.offsetHeight + "px";
72
+ const f = Ce({
73
+ anchor: p,
74
+ anchorAlign: h,
75
+ element: e,
76
+ elementAlign: v,
77
+ offset: N,
78
+ margin: F,
79
+ positionMode: H,
80
+ scale: oe
81
+ }), a = xe({
82
+ anchor: p,
83
+ anchorAlign: h,
84
+ element: e,
85
+ elementAlign: v,
86
+ collisions: m,
87
+ currentLocation: f,
88
+ margin: F
89
+ });
90
+ if (e.style.top = a.offset.top + "px", e.style.left = a.offset.left + "px", e.style.width = r, e.style.height = d, _.current = {
91
+ fit: a.fit,
92
+ fitted: a.fitted,
93
+ flip: a.flip,
94
+ flipped: a.flipped
95
+ }, q) {
96
+ const x = {
97
+ target: E.current,
98
+ flipped: a.flipped,
99
+ fitted: a.fitted
100
+ };
101
+ q.call(void 0, x);
20
102
  }
21
- );
22
- });
23
- a.displayName = "Popup";
103
+ }, ae = () => {
104
+ const e = c.current;
105
+ e && (y && e.classList.add(
106
+ ...D(A.animationContainerShown({ c: C })).split(" ").filter((r) => r)
107
+ ), fe(e), V && V.call(void 0, { target: E.current }));
108
+ }, G = (e, r, d) => {
109
+ if (!v)
110
+ return;
111
+ let f;
112
+ const { horizontal: a, vertical: x } = v;
113
+ a === "left" && x === "center" ? f = "right" : a === "right" && x === "center" ? f = "left" : x === "top" ? f = "down" : f = "up";
114
+ const ge = {
115
+ down: "up",
116
+ up: "down",
117
+ left: "right",
118
+ right: "left"
119
+ };
120
+ _.current && _.current.flipped && (f = ge[f]), ve(e, f, pe()[r], r, d, C);
121
+ }, J = (e) => {
122
+ var f;
123
+ const r = ((f = e == null ? void 0 : e.target) == null ? void 0 : f.closest(".k-animation-container")) === null, d = (p == null ? void 0 : p.contains(e == null ? void 0 : e.target)) || !1;
124
+ if (r) {
125
+ if (X) {
126
+ const a = {
127
+ target: E.current,
128
+ event: e,
129
+ state: o,
130
+ isAnchorClicked: d
131
+ };
132
+ X.call(void 0, a);
133
+ }
134
+ window == null || window.removeEventListener("mousedown", J);
135
+ }
136
+ }, ue = (e) => {
137
+ if (!y) {
138
+ const r = S && S.uPopup;
139
+ e.classList.remove(
140
+ ...D(A.animationContainerShown({ c: r })).split(" ").filter((d) => d)
141
+ );
142
+ }
143
+ Z();
144
+ }, Q = () => {
145
+ o.current === "hiding" && o.previous === "shown" && U({ ...o, current: "hidden", previous: o.current }), W && W.call(void 0, { target: E.current });
146
+ }, pe = () => {
147
+ const e = ne;
148
+ let r = 0, d = 0;
149
+ return e && (e === !0 ? r = d = 300 : (r = e.openDuration || 0, d = e.closeDuration || 0)), { enter: r, exit: d };
150
+ }, fe = (e) => {
151
+ Z(), O.current = De.scrollableParents(p || e), O.current && O.current.map((r) => r.addEventListener("scroll", K)), window.addEventListener("resize", K);
152
+ }, Z = () => {
153
+ O.current && (O.current.map((e) => e.removeEventListener("scroll", K)), O.current = void 0), window.removeEventListener("resize", K);
154
+ }, K = Ae(() => {
155
+ n.current !== "hidden" && n.current !== "hiding" && U({ ...n, current: "reposition", previous: n.current });
156
+ }, Te), de = () => Y ? Y + Ie : ze, Y = Oe() || 0, _ = i.useRef(), O = i.useRef(), c = i.useRef(null), E = i.useRef(null), $ = i.useRef({}), j = i.useRef(!1);
157
+ i.useImperativeHandle(E, () => ({
158
+ element: c.current,
159
+ setPosition: k,
160
+ props: l
161
+ })), i.useImperativeHandle(u, () => E.current);
162
+ const o = i.useMemo(() => {
163
+ const e = {
164
+ ...n,
165
+ props: {
166
+ show: y,
167
+ anchor: p,
168
+ anchorAlign: h,
169
+ appendTo: P,
170
+ collision: m,
171
+ popupAlign: v,
172
+ className: I,
173
+ popupClass: M,
174
+ style: L,
175
+ offset: N,
176
+ contentKey: z
177
+ }
178
+ };
179
+ return y ? n.current === "hidden" || n.current === "hiding" ? { ...e, current: "showing", previous: n.current } : n.current === "showing" ? { ...e, current: "shown", previous: n.current } : n.current === "shown" && (!b(N, n.props.offset) || !b(h, n.props.anchorAlign) || !b(P, n.props.appendTo) || !b(m, n.props.collision) || !b(v, n.props.popupAlign) || !b(L, n.props.style) || p !== n.props.anchor || M !== n.props.popupClass || I !== n.props.className) ? { ...e, current: "reposition", previous: n.current } : e : n.current === "hiding" || n.current === "hidden" ? { ...e, current: "hidden", previous: n.current } : { ...e, current: "hiding", previous: n.current };
180
+ }, [
181
+ y,
182
+ p,
183
+ h,
184
+ P,
185
+ m,
186
+ v,
187
+ I,
188
+ M,
189
+ L,
190
+ N,
191
+ z,
192
+ n
193
+ ]);
194
+ i.useEffect(() => {
195
+ o.current === "hiding" && !j.current && c.current ? (j.current = !0, ue(c.current), G(c.current.firstChild, "exit", Q)) : (j.current = !1, o.current === "showing" && c.current ? B(c.current) : o.current === "hiding" && c.current ? Q() : o.current === "reposition" && o.previous === "shown" ? setTimeout(() => {
196
+ U({ ...o, current: "shown", previous: o.current });
197
+ }, 0) : o.current === "shown" && $.current.contentKey !== z && c.current && k(c.current)), $.current = { contentKey: z };
198
+ }, [o]), i.useEffect(() => (o.current === "showing" && c.current && B(c.current), () => {
199
+ Z();
200
+ }), []);
201
+ const ee = P || (Ee ? p && p.ownerDocument ? p.ownerDocument.body : document.body : void 0);
202
+ o.current === "reposition" && o.previous === "shown" && c.current && k(c.current);
203
+ const me = Object.assign(
204
+ {},
205
+ { position: H, top: 0, left: -1e4 },
206
+ L || {}
207
+ ), he = o.current === "hiding";
208
+ if ((y || he) && ee) {
209
+ const e = de(), r = /* @__PURE__ */ i.createElement(be.Provider, { value: e }, /* @__PURE__ */ i.createElement(
210
+ "div",
211
+ {
212
+ onKeyDown: ie,
213
+ className: D(A.animationContainer({ c: C }), I),
214
+ id: se,
215
+ ref: c,
216
+ style: {
217
+ zIndex: e,
218
+ ...me
219
+ }
220
+ },
221
+ /* @__PURE__ */ i.createElement(
222
+ "div",
223
+ {
224
+ className: D(A.animationChild({ c: C })),
225
+ style: { transitionDelay: "0ms" }
226
+ },
227
+ /* @__PURE__ */ i.createElement("div", { role: re, className: D(A.popup({ c: C }), M) }, ce)
228
+ )
229
+ ));
230
+ return P !== null ? we.createPortal(r, ee) : r;
231
+ }
232
+ return null;
233
+ }), g = {
234
+ collision: {
235
+ horizontal: w.fit,
236
+ vertical: w.flip
237
+ },
238
+ anchorAlign: {
239
+ horizontal: s.left,
240
+ vertical: s.bottom
241
+ },
242
+ popupAlign: {
243
+ horizontal: s.left,
244
+ vertical: s.top
245
+ },
246
+ offset: Me,
247
+ animate: !0,
248
+ show: !1,
249
+ margin: {
250
+ horizontal: 0,
251
+ vertical: 0
252
+ },
253
+ positionMode: "absolute"
254
+ };
255
+ te.displayName = "Popup";
256
+ te.propTypes = {
257
+ anchor: function(l) {
258
+ const u = l.anchor;
259
+ return u && typeof u.nodeType != "number" ? new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. Validation failed.") : null;
260
+ },
261
+ appendTo: function(l) {
262
+ const u = l.appendTo;
263
+ return u && typeof u.nodeType != "number" ? new Error("Invalid prop `appendTo` supplied to `Kendo React Popup`. Validation failed.") : null;
264
+ },
265
+ className: t.oneOfType([t.string, t.arrayOf(t.string.isRequired)]),
266
+ id: t.string,
267
+ popupClass: t.oneOfType([t.string, t.arrayOf(t.string), t.object]),
268
+ collision: t.shape({
269
+ horizontal: t.oneOf([w.fit, w.flip, w.none]),
270
+ vertical: t.oneOf([w.fit, w.flip, w.none])
271
+ }),
272
+ anchorAlign: t.shape({
273
+ horizontal: t.oneOf([s.left, s.center, s.right]),
274
+ vertical: t.oneOf([s.top, s.center, s.bottom])
275
+ }),
276
+ popupAlign: t.shape({
277
+ horizontal: t.oneOf([s.left, s.center, s.right]),
278
+ vertical: t.oneOf([s.top, s.center, s.bottom])
279
+ }),
280
+ offset: t.shape({
281
+ left: t.number,
282
+ top: t.number
283
+ }),
284
+ children: t.oneOfType([t.element, t.node]),
285
+ show: t.bool,
286
+ animate: t.oneOfType([
287
+ t.bool,
288
+ t.shape({
289
+ openDuration: t.number,
290
+ closeDuration: t.number
291
+ })
292
+ ]),
293
+ margin: t.shape({
294
+ horizontal: t.number,
295
+ vertical: t.number
296
+ }),
297
+ positionMode: t.oneOf(["fixed", "absolute"]),
298
+ scale: t.number,
299
+ style: t.object,
300
+ onClose: t.func,
301
+ onPosition: t.func,
302
+ onOpen: t.func,
303
+ onKeyDown: t.func,
304
+ onMouseDownOutside: t.func
305
+ };
24
306
  export {
25
- a as Popup,
26
- u as PopupPropsContext
307
+ te as Popup,
308
+ Ne as PopupPropsContext,
309
+ g as popupDefaultProps
27
310
  };
package/README.md CHANGED
@@ -5,10 +5,11 @@
5
5
  # KendoReact Popup Component for React
6
6
 
7
7
  > **Important**
8
- > * This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)&mdash;a commercial UI library.
9
- > * You will need to install a license key when adding the package to your project. For more information, please refer to the [KendoReact My License page](https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup).
10
- > * To receive a license key, you need to either [purchase a license](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup) or register for a [free trial](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup). Doing so indicates that you [accept the KendoReact License Agreement](https://www.telerik.com/purchase/license-agreement/progress-kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup).
11
- > * The 30-day free trial gives you access to all the KendoReact components and their full functionality. Additionally, for the period of your license, you get access to our legendary technical support provided directly by the KendoReact dev team!
8
+ >
9
+ > - This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)&mdash;a commercial UI library.
10
+ > - You will need to install a license key when adding the package to your project. For more information, please refer to the [KendoReact My License page](https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup).
11
+ > - To receive a license key, you need to either [purchase a license](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup) or register for a [free trial](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup). Doing so indicates that you [accept the KendoReact License Agreement](https://www.telerik.com/purchase/license-agreement/progress-kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup).
12
+ > - The 30-day free trial gives you access to all the KendoReact components and their full functionality. Additionally, for the period of your license, you get access to our legendary technical support provided directly by the KendoReact dev team!
12
13
  >
13
14
  > [Start using KendoReact](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup) and speed up your development process!
14
15
 
@@ -18,35 +19,35 @@ The [React Popup](https://www.telerik.com/kendo-react-ui/popup), part of KendoRe
18
19
 
19
20
  Among the features which the KendoReact Popup component delivers are:
20
21
 
21
- * [Hidden popup](https://www.telerik.com/kendo-react-ui/components/popup/hidden-state/)&mdash;The Popup enables you to control its visibility.
22
- * [Animations](https://www.telerik.com/kendo-react-ui/components/popup/animations/)&mdash;The Popup allows you to enable or disable its opening and closing animation.
23
- * [Aligning and positioning](https://www.telerik.com/kendo-react-ui/components/popup/aligning-positioning/)&mdash;The Popup enables you to align it to components and absolute points as well as to control its position.
24
- * [Viewport boundary detection](https://www.telerik.com/kendo-react-ui/components/popup/viewport-boundary/)&mdash;The Popup enables you to set its boundary detection functionality by using the collision property. This controls the behavior of the component when it does not fit in the view port.
25
- * [Theme support](https://www.telerik.com/kendo-react-ui/components/styling/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)&mdash;The KendoReact Popup, as well as all 100+ components in the KendoReact suite, are styled in three polished themes (Bootstrap, Material, and Default) and can be further customized to match your specific design guidelines.
22
+ - [Hidden popup](https://www.telerik.com/kendo-react-ui/components/popup/hidden-state/)&mdash;The Popup enables you to control its visibility.
23
+ - [Animations](https://www.telerik.com/kendo-react-ui/components/popup/animations/)&mdash;The Popup allows you to enable or disable its opening and closing animation.
24
+ - [Aligning and positioning](https://www.telerik.com/kendo-react-ui/components/popup/aligning-positioning/)&mdash;The Popup enables you to align it to components and absolute points as well as to control its position.
25
+ - [Viewport boundary detection](https://www.telerik.com/kendo-react-ui/components/popup/viewport-boundary/)&mdash;The Popup enables you to set its boundary detection functionality by using the collision property. This controls the behavior of the component when it does not fit in the view port.
26
+ - [Theme support](https://www.telerik.com/kendo-react-ui/components/styling/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)&mdash;The KendoReact Popup, as well as all 100+ components in the KendoReact suite, are styled in three polished themes (Bootstrap, Material, and Default) and can be further customized to match your specific design guidelines.
26
27
 
27
28
  ## Support Options
28
29
 
29
30
  For any issues you might encounter while working with the KendoReact Popup, use any of the available support channels:
30
31
 
31
- * Industry-leading technical support&mdash;KendoReact paid license holders and users with an active (free) trial license can take advantage of our outstanding customer support. To submit a ticket, use [the dedicated KendoReact support system](https://www.telerik.com/account/support-tickets?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup).
32
- * Product forums&mdash;The [KendoReact forums](https://www.telerik.com/forums/kendo-ui-react?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup) are part of the free support you can get from the community and from the KendoReact team.
33
- * Feedback portal&mdash;The [KendoReact feedback portal](https://feedback.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup) is where you can request and vote for new features to be added.
32
+ - Industry-leading technical support&mdash;KendoReact paid license holders and users with an active (free) trial license can take advantage of our outstanding customer support. To submit a ticket, use [the dedicated KendoReact support system](https://www.telerik.com/account/support-tickets?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup).
33
+ - Product forums&mdash;The [KendoReact forums](https://www.telerik.com/forums/kendo-ui-react?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup) are part of the free support you can get from the community and from the KendoReact team.
34
+ - Feedback portal&mdash;The [KendoReact feedback portal](https://feedback.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup) is where you can request and vote for new features to be added.
34
35
 
35
36
  ## Resources
36
37
 
37
- * [Getting Started with KendoReact](https://www.telerik.com/kendo-react-ui/components/getting-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
38
- * [Get Started with the KendoReact Popup](https://www.telerik.com/kendo-react-ui/components/popup/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
39
- * [API Reference of the KendoReact Popup](https://www.telerik.com/kendo-react-ui/components/popup/api/PopupProps/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
40
- * [KendoReact Roadmap](https://www.telerik.com/support/whats-new/kendo-react-ui/roadmap?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
41
- * [Blogs](https://www.telerik.com/blogs/tag/kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
42
- * [Demos, documentation, and component reference](https://www.telerik.com/kendo-react-ui/components/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
43
- * [KendoReact pricing and licensing](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
44
- * [Changelog](https://www.telerik.com/kendo-react-ui/components/changelogs/ui-for-react/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
38
+ - [Getting Started with KendoReact](https://www.telerik.com/kendo-react-ui/components/getting-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
39
+ - [Get Started with the KendoReact Popup](https://www.telerik.com/kendo-react-ui/components/popup/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
40
+ - [API Reference of the KendoReact Popup](https://www.telerik.com/kendo-react-ui/components/popup/api/PopupProps/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
41
+ - [KendoReact Roadmap](https://www.telerik.com/support/whats-new/kendo-react-ui/roadmap?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
42
+ - [Blogs](https://www.telerik.com/blogs/tag/kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
43
+ - [Demos, documentation, and component reference](https://www.telerik.com/kendo-react-ui/components/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
44
+ - [KendoReact pricing and licensing](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
45
+ - [Changelog](https://www.telerik.com/kendo-react-ui/components/changelogs/ui-for-react/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-popup)
45
46
 
46
47
  High-level component overview pages
47
48
 
48
- * [React Popup Component](https://www.telerik.com/kendo-react-ui/popup)
49
+ - [React Popup Component](https://www.telerik.com/kendo-react-ui/popup)
49
50
 
50
- *Copyright © 2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.*
51
+ _Copyright © 2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved._
51
52
 
52
- *Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries.*
53
+ _Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries._
package/animation.js CHANGED
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@progress/kendo-react-common"),w=(i,s,n)=>{i.style.transitionDuration="",s&&i.classList.remove(...s.split(" ")),s&&i.classList.remove(...n.split(" "))},p=typeof window!="undefined"&&/Firefox/.test(window.navigator.userAgent),y=(i,s,n,r,d,u)=>{if(n===0)return d();const o=e.classNames(e.uPopup.slide({direction:s,type:r,c:u})),a=e.classNames(e.uPopup.slideActive({direction:s,type:r,c:u})),f=t=>{t.target===i&&(i.removeEventListener("transitionend",f),w(i,o,a),r==="exit"?i.style.display="none":i.style.display="",d())};i.addEventListener("transitionend",f);const l=i.ownerDocument;if(!l)return;const c=l.defaultView;if(!c)return;const v=()=>{w(i,o,a),o&&i.classList.add(...o.split(" ").filter(t=>t)),c.requestAnimationFrame(()=>{i.style.transitionDuration=n+"ms",i.classList.add(...a.split(" ").filter(t=>t))})};p?c.requestAnimationFrame(v):v()};exports.slide=y;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@progress/kendo-react-common"),w=(i,s,t)=>{i.style.transitionDuration="",s&&i.classList.remove(...s.split(" ")),t&&i.classList.remove(...t.split(" "))},y=typeof window!="undefined"&&/Firefox/.test(window.navigator.userAgent),p=(i,s,t,o,c,f)=>{if(t===0)return c();const r=e.classNames(e.uPopup.slide({direction:s,type:o,c:f})),a=e.classNames(e.uPopup.slideActive({direction:s,type:o,c:f})),u=n=>{n.target===i&&(i.removeEventListener("transitionend",u),w(i,r,a),o==="exit"?i.style.display="none":i.style.display="",c())};i.addEventListener("transitionend",u);const l=i.ownerDocument;if(!l)return;const d=l.defaultView;if(!d)return;const v=()=>{w(i,r,a),o==="enter"&&(i.style.display=""),r&&i.classList.add(...r.split(" ").filter(n=>n)),d.requestAnimationFrame(()=>{i.style.transitionDuration=t+"ms",i.classList.add(...a.split(" ").filter(n=>n))})};y?d.requestAnimationFrame(v):v()};exports.slide=p;
package/animation.mjs CHANGED
@@ -6,16 +6,16 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import { classNames as v, uPopup as w } from "@progress/kendo-react-common";
10
- const p = (i, s, n) => {
11
- i.style.transitionDuration = "", s && i.classList.remove(...s.split(" ")), s && i.classList.remove(...n.split(" "));
12
- }, L = typeof window != "undefined" && /Firefox/.test(window.navigator.userAgent), A = (i, s, n, r, c, d) => {
13
- if (n === 0)
14
- return c();
15
- const o = v(w.slide({ direction: s, type: r, c: d })), a = v(w.slideActive({ direction: s, type: r, c: d })), f = (t) => {
16
- t.target === i && (i.removeEventListener("transitionend", f), p(i, o, a), r === "exit" ? i.style.display = "none" : i.style.display = "", c());
9
+ import { classNames as w, uPopup as v } from "@progress/kendo-react-common";
10
+ const p = (i, s, t) => {
11
+ i.style.transitionDuration = "", s && i.classList.remove(...s.split(" ")), t && i.classList.remove(...t.split(" "));
12
+ }, y = typeof window != "undefined" && /Firefox/.test(window.navigator.userAgent), x = (i, s, t, r, d, f) => {
13
+ if (t === 0)
14
+ return d();
15
+ const o = w(v.slide({ direction: s, type: r, c: f })), a = w(v.slideActive({ direction: s, type: r, c: f })), c = (n) => {
16
+ n.target === i && (i.removeEventListener("transitionend", c), p(i, o, a), r === "exit" ? i.style.display = "none" : i.style.display = "", d());
17
17
  };
18
- i.addEventListener("transitionend", f);
18
+ i.addEventListener("transitionend", c);
19
19
  const u = i.ownerDocument;
20
20
  if (!u)
21
21
  return;
@@ -23,12 +23,12 @@ const p = (i, s, n) => {
23
23
  if (!e)
24
24
  return;
25
25
  const l = () => {
26
- p(i, o, a), o && i.classList.add(...o.split(" ").filter((t) => t)), e.requestAnimationFrame(() => {
27
- i.style.transitionDuration = n + "ms", i.classList.add(...a.split(" ").filter((t) => t));
26
+ p(i, o, a), r === "enter" && (i.style.display = ""), o && i.classList.add(...o.split(" ").filter((n) => n)), e.requestAnimationFrame(() => {
27
+ i.style.transitionDuration = t + "ms", i.classList.add(...a.split(" ").filter((n) => n));
28
28
  });
29
29
  };
30
- L ? e.requestAnimationFrame(l) : l();
30
+ y ? e.requestAnimationFrame(l) : l();
31
31
  };
32
32
  export {
33
- A as slide
33
+ x as slide
34
34
  };
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-dom"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-popup-common")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-common","@progress/kendo-popup-common"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).KendoReactPopup={},t.React,t.ReactDOM,t.PropTypes,t.KendoReactCommon,t.KendoPopupCommon)}(this,(function(t,e,o,n,i,s){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}})),e.default=t,Object.freeze(e)}var p=r(e),l=r(o);const a=(t,e,o)=>{t.style.transitionDuration="",e&&t.classList.remove(...e.split(" ")),e&&t.classList.remove(...o.split(" "))},c="undefined"!=typeof window&&/Firefox/.test(window.navigator.userAgent),u={name:"@progress/kendo-react-popup",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"};function h(t,e){if(t===e)return!0;if(!!t!=!!e)return!1;const o=Object.getOwnPropertyNames(t),n=Object.getOwnPropertyNames(e);if(o.length!==n.length)return!1;for(let n=0;n<o.length;n++){const i=o[n];if(t[i]!==e[i])return!1}return!0}const d=class extends p.Component{constructor(t){super(t),this.context=0,this.state={current:"hidden",previous:"hidden",props:{}},this._popup=null,this.show=t=>{null==window||window.addEventListener("mousedown",this.handleMouseDown),this.setPosition(t),this.animate(t.firstChild,"enter",this.onOpened),this.setState({current:"shown",previous:this.state.current})},this.setPosition=t=>{const{anchorAlign:e,popupAlign:o,collision:n,offset:i,anchor:r,margin:p,scale:l,positionMode:a}=this.props,{width:c,height:u}=t.style;t.style.width=t.offsetWidth+"px",t.style.height=t.offsetHeight+"px";const h=s.alignElement({anchor:r,anchorAlign:e,element:t,elementAlign:o,offset:i,margin:p,positionMode:a,scale:l}),d=s.positionElement({anchor:r,anchorAlign:e,element:t,elementAlign:o,collisions:n,currentLocation:h,margin:this.props.margin});if(t.style.top=d.offset.top+"px",t.style.left=d.offset.left+"px",t.style.width=c,t.style.height=u,this._collisions={fit:d.fit,fitted:d.fitted,flip:d.flip,flipped:d.flipped},this.props.onPosition){const t={target:this,flipped:d.flipped,fitted:d.fitted};this.props.onPosition.call(void 0,t)}},this.onOpened=()=>{const t=this._popup;if(t){if(this.props.show){const{unstyled:e}=this.props,o=e&&e.uPopup;t.classList.add(...i.classNames(i.uPopup.animationContainerShown({c:o})).split(" ").filter((t=>t)))}this.attachRepositionHandlers(t),this.props.onOpen&&this.props.onOpen.call(void 0,{target:this})}},this.animate=(t,e,o)=>{if(!this.props.popupAlign)return;let n;const{horizontal:s,vertical:r}=this.props.popupAlign;n="left"===s&&"center"===r?"right":"right"===s&&"center"===r?"left":"top"===r?"down":"up";this._collisions&&this._collisions.flipped&&(n={down:"up",up:"down",left:"right",right:"left"}[n]);const{unstyled:p}=this.props,l=p&&p.uPopup;((t,e,o,n,s,r)=>{if(0===o)return s();const p=i.classNames(i.uPopup.slide({direction:e,type:n,c:r})),l=i.classNames(i.uPopup.slideActive({direction:e,type:n,c:r})),u=e=>{e.target===t&&(t.removeEventListener("transitionend",u),a(t,p,l),t.style.display="exit"===n?"none":"",s())};t.addEventListener("transitionend",u);const h=t.ownerDocument;if(!h)return;const d=h.defaultView;if(!d)return;const f=()=>{a(t,p,l),p&&t.classList.add(...p.split(" ").filter((t=>t))),d.requestAnimationFrame((()=>{t.style.transitionDuration=o+"ms",t.classList.add(...l.split(" ").filter((t=>t)))}))};c?d.requestAnimationFrame(f):f()})(t,n,this.animationDuration[e],e,o,l)},this.handleMouseDown=t=>{var e,o;const n=null===(null==(e=null==t?void 0:t.target)?void 0:e.closest(".k-animation-container")),i=(null==(o=this.props.anchor)?void 0:o.contains(null==t?void 0:t.target))||!1;if(n){if(this.props.onMouseDownOutside){const e={target:this,event:t,state:this.state,isAnchorClicked:i};this.props.onMouseDownOutside.call(void 0,e)}null==window||window.removeEventListener("mousedown",this.handleMouseDown)}},this.onClosing=t=>{if(!this.props.show){const{unstyled:e}=this.props,o=e&&e.uPopup;t.classList.remove(...i.classNames(i.uPopup.animationContainerShown({c:o})).split(" ").filter((t=>t)))}this.detachRepositionHandlers()},this.onClosed=()=>{"hiding"===this.state.current&&"shown"===this.state.previous&&this.setState({current:"hidden",previous:this.state.current}),this.props.onClose&&this.props.onClose.call(void 0,{target:this})},this.getCurrentZIndex=()=>this.context?this.context+1:100,i.validatePackage(u),this.reposition=function(t,e,o={}){let n,i,s,r,p=0;o=o||{};const l=function(){p=!1===o.leading?0:(new Date).getTime(),n=void 0,r=t.apply(i,s),n||(i=s=null)};return function(){const a=(new Date).getTime();!p&&!1===o.leading&&(p=a);const c=e-(a-p);return i=void 0,s=arguments,c<=0||c>e?(n&&(clearTimeout(n),n=void 0),p=a,r=t.apply(i,s),n||(i=s=null)):!n&&!1!==o.trailing&&(n=window.setTimeout(l,c)),r}}(this.reposition.bind(this),16.666666666666668)}get element(){return this._popup}static getDerivedStateFromProps(t,e){const{show:o,anchor:n,anchorAlign:i,appendTo:s,collision:r,popupAlign:p,className:l,popupClass:a,style:c,offset:u,contentKey:d}=t,f={...e,props:{show:o,anchor:n,anchorAlign:i,appendTo:s,collision:r,popupAlign:p,className:l,popupClass:a,style:c,offset:u,contentKey:d}};return t.show?"hidden"===e.current||"hiding"===e.current?{...f,current:"showing",previous:e.current}:"showing"===e.current?{...f,current:"shown",previous:e.current}:"shown"!==e.current||h(u,e.props.offset)&&h(i,e.props.anchorAlign)&&h(s,e.props.appendTo)&&h(r,e.props.collision)&&h(p,e.props.popupAlign)&&h(c,e.props.style)&&n===e.props.anchor&&a===e.props.popupClass&&l===e.props.className?f:{...f,current:"reposition",previous:e.current}:"hiding"===e.current||"hidden"===e.current?{...f,current:"hidden",previous:e.current}:{...f,current:"hiding",previous:e.current}}componentDidUpdate(t){"showing"===this.state.current&&this._popup?this.show(this._popup):"hiding"===this.state.current&&this._popup?(this.onClosing(this._popup),this.animate(this._popup.firstChild,"exit",this.onClosed)):"reposition"===this.state.current&&"shown"===this.state.previous?setTimeout((()=>{this.setState({current:"shown",previous:this.state.current})}),0):"shown"===this.state.current&&t.contentKey!==this.props.contentKey&&this._popup&&this.setPosition(this._popup)}componentDidMount(){"showing"===this.state.current&&this._popup&&this.show(this._popup)}componentWillUnmount(){this.detachRepositionHandlers()}render(){const{children:t,className:e,popupClass:o,unstyled:n,show:s,id:r,positionMode:a}=this.props,c=n&&n.uPopup,u=this.props.appendTo?this.props.appendTo:i.canUseDOM?this.props.anchor&&this.props.anchor.ownerDocument?this.props.anchor.ownerDocument.body:document.body:void 0;"reposition"===this.state.current&&"shown"===this.state.previous&&this._popup&&this.setPosition(this._popup);const h=Object.assign({},{position:a,top:0,left:-1e4},this.props.style||{}),d="hiding"===this.state.current;if((s||d)&&u){const n=this.getCurrentZIndex(),s=p.createElement(i.ZIndexContext.Provider,{value:n},p.createElement("div",{onKeyDown:this.props.onKeyDown,className:i.classNames(i.uPopup.animationContainer({c:c}),e),id:r,ref:t=>this._popup=t,style:{zIndex:n,...h}},p.createElement("div",{className:i.classNames(i.uPopup.animationChild({c:c})),style:{transitionDelay:"0ms"}},p.createElement("div",{role:this.props.role,className:i.classNames(i.uPopup.popup({c:c}),o)},t))));return null!==this.props.appendTo?l.createPortal(s,u):s}return null}get animationDuration(){const t=this.props.animate;let e=0,o=0;return t&&(!0===t?e=o=300:(e=t.openDuration||0,o=t.closeDuration||0)),{enter:e,exit:o}}attachRepositionHandlers(t){this.detachRepositionHandlers(),this._scrollableParents=s.domUtils.scrollableParents(this.props.anchor||t),this._scrollableParents&&this._scrollableParents.map((t=>t.addEventListener("scroll",this.reposition))),window.addEventListener("resize",this.reposition)}detachRepositionHandlers(){this._scrollableParents&&(this._scrollableParents.map((t=>t.removeEventListener("scroll",this.reposition))),this._scrollableParents=void 0),window.removeEventListener("resize",this.reposition)}reposition(){this.setState({current:"reposition",previous:this.state.current})}};d.propTypes={anchor:function(t){const e=t.anchor;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. Validation failed."):null},appendTo:function(t){const e=t.appendTo;return e&&"number"!=typeof e.nodeType?new Error("Invalid prop `appendTo` supplied to `Kendo React Popup`. Validation failed."):null},className:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),id:n.string,popupClass:n.oneOfType([n.string,n.arrayOf(n.string),n.object]),collision:n.shape({horizontal:n.oneOf([s.Collision.fit,s.Collision.flip,s.Collision.none]),vertical:n.oneOf([s.Collision.fit,s.Collision.flip,s.Collision.none])}),anchorAlign:n.shape({horizontal:n.oneOf([s.AlignPoint.left,s.AlignPoint.center,s.AlignPoint.right]),vertical:n.oneOf([s.AlignPoint.top,s.AlignPoint.center,s.AlignPoint.bottom])}),popupAlign:n.shape({horizontal:n.oneOf([s.AlignPoint.left,s.AlignPoint.center,s.AlignPoint.right]),vertical:n.oneOf([s.AlignPoint.top,s.AlignPoint.center,s.AlignPoint.bottom])}),offset:n.shape({left:n.number,top:n.number}),children:n.oneOfType([n.element,n.node]),show:n.bool,animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),margin:n.shape({horizontal:n.number,vertical:n.number}),positionMode:n.oneOf(["fixed","absolute"]),scale:n.number,style:n.object,onClose:n.func,onPosition:n.func,onOpen:n.func,onKeyPress:n.func,onMouseDownOutside:n.func},d.defaultProps={collision:{horizontal:s.Collision.fit,vertical:s.Collision.flip},anchorAlign:{horizontal:s.AlignPoint.left,vertical:s.AlignPoint.bottom},popupAlign:{horizontal:s.AlignPoint.left,vertical:s.AlignPoint.top},offset:{left:-1e3,top:0},animate:!0,show:!1,margin:{horizontal:0,vertical:0},positionMode:"absolute"},d.contextType=i.ZIndexContext,d.displayName="PopupComponent";let f=d;const m=p.createContext((t=>t)),g=p.forwardRef(((t,e)=>{const o=p.useContext(m),n=i.useUnstyled(),s=o.call(void 0,t);return p.createElement(f,{ref:e,unstyled:n,...s})}));g.displayName="Popup",t.Popup=g,t.PopupPropsContext=m,t.PopupWithoutContext=f}));
8
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("react-dom"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-popup-common")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","prop-types","@progress/kendo-react-common","@progress/kendo-popup-common"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactPopup={},e.React,e.ReactDOM,e.PropTypes,e.KendoReactCommon,e.KendoPopupCommon)}(this,(function(e,n,t,o,r,i){"use strict";function s(e){var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var l=s(n),c=s(t);const u=(e,n,t)=>{e.style.transitionDuration="",n&&e.classList.remove(...n.split(" ")),t&&e.classList.remove(...t.split(" "))},p="undefined"!=typeof window&&/Firefox/.test(window.navigator.userAgent),a=(e,n,t,o,i,s)=>{if(0===t)return i();const l=r.classNames(r.uPopup.slide({direction:n,type:o,c:s})),c=r.classNames(r.uPopup.slideActive({direction:n,type:o,c:s})),a=n=>{n.target===e&&(e.removeEventListener("transitionend",a),u(e,l,c),e.style.display="exit"===o?"none":"",i())};e.addEventListener("transitionend",a);const d=e.ownerDocument;if(!d)return;const f=d.defaultView;if(!f)return;const m=()=>{u(e,l,c),"enter"===o&&(e.style.display=""),l&&e.classList.add(...l.split(" ").filter((e=>e))),f.requestAnimationFrame((()=>{e.style.transitionDuration=t+"ms",e.classList.add(...c.split(" ").filter((e=>e)))}))};p?f.requestAnimationFrame(m):m()},d={name:"@progress/kendo-react-popup",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},f=l.createContext((e=>e));function m(e,n){if(e===n)return!0;if(!!e!=!!n)return!1;const t=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(n);if(t.length!==o.length)return!1;for(let o=0;o<t.length;o++){const r=t[o];if(e[r]!==n[r])return!1}return!0}const g=l.forwardRef(((e,n)=>{const t=l.useContext(f).call(void 0,e);r.validatePackage(d);const{collision:o=h.collision,anchorAlign:s=h.anchorAlign,popupAlign:u=h.popupAlign,offset:p=h.offset,animate:g=h.animate,show:v=h.show,margin:w=h.margin,positionMode:y=h.positionMode,appendTo:P,contentKey:A,anchor:b,scale:O,role:C,onKeyDown:D,onPosition:E,onOpen:T,onMouseDownOutside:x,onClose:N,className:L,popupClass:R,id:K,style:z,children:j}=t,k=r.useUnstyled(),M=t.unstyled||k,I=M&&M.uPopup,[q,U]=l.useState({current:"hidden",previous:"hidden",props:{}}),F=e=>{null==window||window.addEventListener("mousedown",Z),H(e),V(e.firstChild,"enter",S),U({...oe,current:"shown",previous:oe.current})},H=e=>{const{width:n,height:t}=e.style;e.style.width=e.offsetWidth+"px",e.style.height=e.offsetHeight+"px";const r=i.alignElement({anchor:b,anchorAlign:s,element:e,elementAlign:u,offset:p,margin:w,positionMode:y,scale:O}),l=i.positionElement({anchor:b,anchorAlign:s,element:e,elementAlign:u,collisions:o,currentLocation:r,margin:w});if(e.style.top=l.offset.top+"px",e.style.left=l.offset.left+"px",e.style.width=n,e.style.height=t,Y.current={fit:l.fit,fitted:l.fitted,flip:l.flip,flipped:l.flipped},E){const e={target:ee.current,flipped:l.flipped,fitted:l.fitted};E.call(void 0,e)}},S=()=>{const e=_.current;e&&(v&&e.classList.add(...r.classNames(r.uPopup.animationContainerShown({c:I})).split(" ").filter((e=>e))),G(e),T&&T.call(void 0,{target:ee.current}))},V=(e,n,t)=>{if(!u)return;let o;const{horizontal:r,vertical:i}=u;o="left"===r&&"center"===i?"right":"right"===r&&"center"===i?"left":"top"===i?"down":"up";Y.current&&Y.current.flipped&&(o={down:"up",up:"down",left:"right",right:"left"}[o]),a(e,o,B()[n],n,t,I)},Z=e=>{var n;const t=null===(null==(n=null==e?void 0:e.target)?void 0:n.closest(".k-animation-container")),o=(null==b?void 0:b.contains(null==e?void 0:e.target))||!1;if(t){if(x){const n={target:ee.current,event:e,state:oe,isAnchorClicked:o};x.call(void 0,n)}null==window||window.removeEventListener("mousedown",Z)}},W=()=>{"hiding"===oe.current&&"shown"===oe.previous&&U({...oe,current:"hidden",previous:oe.current}),N&&N.call(void 0,{target:ee.current})},B=()=>{const e=g;let n=0,t=0;return e&&(!0===e?n=t=300:(n=e.openDuration||0,t=e.closeDuration||0)),{enter:n,exit:t}},G=e=>{J(),$.current=i.domUtils.scrollableParents(b||e),$.current&&$.current.map((e=>e.addEventListener("scroll",Q))),window.addEventListener("resize",Q)},J=()=>{$.current&&($.current.map((e=>e.removeEventListener("scroll",Q))),$.current=void 0),window.removeEventListener("resize",Q)},Q=function(e,n,t={}){let o,r,i,s,l=0;t=t||{};const c=function(){l=!1===t.leading?0:(new Date).getTime(),o=void 0,s=e.apply(r,i),o||(r=i=null)};return function(){const u=(new Date).getTime();!l&&!1===t.leading&&(l=u);const p=n-(u-l);return r=void 0,i=arguments,p<=0||p>n?(o&&(clearTimeout(o),o=void 0),l=u,s=e.apply(r,i),o||(r=i=null)):!o&&!1!==t.trailing&&(o=window.setTimeout(c,p)),s}}((()=>{"hidden"!==q.current&&"hiding"!==q.current&&U({...q,current:"reposition",previous:q.current})}),16.666666666666668),X=r.useZIndexContext()||0,Y=l.useRef(),$=l.useRef(),_=l.useRef(null),ee=l.useRef(null),ne=l.useRef({}),te=l.useRef(!1);l.useImperativeHandle(ee,(()=>({element:_.current,setPosition:H,props:e}))),l.useImperativeHandle(n,(()=>ee.current));const oe=l.useMemo((()=>{const e={...q,props:{show:v,anchor:b,anchorAlign:s,appendTo:P,collision:o,popupAlign:u,className:L,popupClass:R,style:z,offset:p,contentKey:A}};return v?"hidden"===q.current||"hiding"===q.current?{...e,current:"showing",previous:q.current}:"showing"===q.current?{...e,current:"shown",previous:q.current}:"shown"!==q.current||m(p,q.props.offset)&&m(s,q.props.anchorAlign)&&m(P,q.props.appendTo)&&m(o,q.props.collision)&&m(u,q.props.popupAlign)&&m(z,q.props.style)&&b===q.props.anchor&&R===q.props.popupClass&&L===q.props.className?e:{...e,current:"reposition",previous:q.current}:"hiding"===q.current||"hidden"===q.current?{...e,current:"hidden",previous:q.current}:{...e,current:"hiding",previous:q.current}}),[v,b,s,P,o,u,L,R,z,p,A,q]);l.useEffect((()=>{"hiding"===oe.current&&!te.current&&_.current?(te.current=!0,(e=>{if(!v){const n=M&&M.uPopup;e.classList.remove(...r.classNames(r.uPopup.animationContainerShown({c:n})).split(" ").filter((e=>e)))}J()})(_.current),V(_.current.firstChild,"exit",W)):(te.current=!1,"showing"===oe.current&&_.current?F(_.current):"hiding"===oe.current&&_.current?W():"reposition"===oe.current&&"shown"===oe.previous?setTimeout((()=>{U({...oe,current:"shown",previous:oe.current})}),0):"shown"===oe.current&&ne.current.contentKey!==A&&_.current&&H(_.current)),ne.current={contentKey:A}}),[oe]),l.useEffect((()=>("showing"===oe.current&&_.current&&F(_.current),()=>{J()})),[]);const re=P||(r.canUseDOM?b&&b.ownerDocument?b.ownerDocument.body:document.body:void 0);"reposition"===oe.current&&"shown"===oe.previous&&_.current&&H(_.current);const ie=Object.assign({},{position:y,top:0,left:-1e4},z||{}),se="hiding"===oe.current;if((v||se)&&re){const e=X?X+1:100,n=l.createElement(r.ZIndexContext.Provider,{value:e},l.createElement("div",{onKeyDown:D,className:r.classNames(r.uPopup.animationContainer({c:I}),L),id:K,ref:_,style:{zIndex:e,...ie}},l.createElement("div",{className:r.classNames(r.uPopup.animationChild({c:I})),style:{transitionDelay:"0ms"}},l.createElement("div",{role:C,className:r.classNames(r.uPopup.popup({c:I}),R)},j))));return null!==P?c.createPortal(n,re):n}return null})),h={collision:{horizontal:i.Collision.fit,vertical:i.Collision.flip},anchorAlign:{horizontal:i.AlignPoint.left,vertical:i.AlignPoint.bottom},popupAlign:{horizontal:i.AlignPoint.left,vertical:i.AlignPoint.top},offset:{left:-1e3,top:0},animate:!0,show:!1,margin:{horizontal:0,vertical:0},positionMode:"absolute"};g.displayName="Popup",g.propTypes={anchor:function(e){const n=e.anchor;return n&&"number"!=typeof n.nodeType?new Error("Invalid prop `anchor` supplied to `Kendo React Popup`. Validation failed."):null},appendTo:function(e){const n=e.appendTo;return n&&"number"!=typeof n.nodeType?new Error("Invalid prop `appendTo` supplied to `Kendo React Popup`. Validation failed."):null},className:o.oneOfType([o.string,o.arrayOf(o.string.isRequired)]),id:o.string,popupClass:o.oneOfType([o.string,o.arrayOf(o.string),o.object]),collision:o.shape({horizontal:o.oneOf([i.Collision.fit,i.Collision.flip,i.Collision.none]),vertical:o.oneOf([i.Collision.fit,i.Collision.flip,i.Collision.none])}),anchorAlign:o.shape({horizontal:o.oneOf([i.AlignPoint.left,i.AlignPoint.center,i.AlignPoint.right]),vertical:o.oneOf([i.AlignPoint.top,i.AlignPoint.center,i.AlignPoint.bottom])}),popupAlign:o.shape({horizontal:o.oneOf([i.AlignPoint.left,i.AlignPoint.center,i.AlignPoint.right]),vertical:o.oneOf([i.AlignPoint.top,i.AlignPoint.center,i.AlignPoint.bottom])}),offset:o.shape({left:o.number,top:o.number}),children:o.oneOfType([o.element,o.node]),show:o.bool,animate:o.oneOfType([o.bool,o.shape({openDuration:o.number,closeDuration:o.number})]),margin:o.shape({horizontal:o.number,vertical:o.number}),positionMode:o.oneOf(["fixed","absolute"]),scale:o.number,style:o.object,onClose:o.func,onPosition:o.func,onOpen:o.func,onKeyDown:o.func,onMouseDownOutside:o.func},e.Popup=g,e.PopupPropsContext=f}));