UNPKG

igniteui-react-core

Version:
989 lines (988 loc) 32.3 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { EventProxy } from "./EventProxy"; import { Point_$type, runOn, markType, PointUtil, String_$type, Delegate_$type } from "./type"; import { Rect } from "./Rect"; import { MouseEventArgs } from "./MouseEventArgs"; import { Dictionary$2 } from "./Dictionary$2"; import { List$1 } from "./List$1"; /** * @hidden */ export let BaseDOMEventProxy = /*@__PURE__*/ (() => { class BaseDOMEventProxy extends EventProxy { constructor() { super(); this.b7 = null; this.by = false; this.b0 = false; this.b6 = null; this.br = false; this.b4 = 0; this.b5 = 0; this.b2 = 0; this.b3 = 0; this.b8 = 0; this.c7 = null; this.c6 = null; this.bq = false; this.b9 = -1; this.bv = false; this.bs = false; this.bp = false; this.ap = 1; } d() { let a = new DOMEventProxy(this.b7, this.b6, this.b0); a.ac = this.ac; a.ar = this.ar; return a; } static get b1() { return (BaseDOMEventProxy.bw || BaseDOMEventProxy.bx); } bn(a) { return DOMEventProxy.c8(a); } bu(e_) { let pointerEvent_ = e_.originalEvent; let a = false; if (BaseDOMEventProxy.bx) { a = (pointerEvent_.pointerType == 'touch'); } else { a = (pointerEvent_.pointerType == pointerEvent_.MSPOINTER_TYPE_TOUCH); } return a; } cy(a) { if (!this.af) { if (this.bt(a)) { if (this.at == null || this.at(a)) { a.preventDefault(); } } } } bt(e_) { return (e_.originalEvent.cancelable || e_.originalEvent.cancelable == undefined); } cu() { let source_ = this.b7.getNativeElement(); BaseDOMEventProxy.cx(source_); } static cx(source_) { if (BaseDOMEventProxy.bx) { source_.style.touchAction = 'none'; } else { source_.style.msTouchAction = 'none'; } source_.style.msUserSelect = 'none'; source_.style.webkitTouchCallout = 'none'; source_.style.webkitUserSelect = 'none'; source_.style.khtmlUserSelect = 'none'; source_.style.mozUserSelect = 'none'; source_.style.userSelect = 'none'; } static cr(source_) { if (BaseDOMEventProxy.bx) { source_.style.touchAction = 'auto'; } else { source_.style.msTouchAction = 'auto'; } source_.style.msUserSelect = 'auto'; source_.style.webkitTouchCallout = 'none'; source_.style.webkitUserSelect = 'auto'; source_.style.khtmlUserSelect = 'auto'; source_.style.mozUserSelect = 'auto'; source_.style.userSelect = 'auto'; } cs() { let source_ = this.b7.getNativeElement(); BaseDOMEventProxy.cr(source_); } ay() { super.ay(); if (!this.af) { this.cu(); } else { this.cs(); } } ce() { let ver_ = -1; let matchIE_ = /Trident\/([\d.]+)/; if ((matchIE_.exec(navigator.userAgent) != null)) { ver_ = (parseFloat(RegExp.$1)); } return ver_; } cd() { let ver_ = -1; let matchIE_ = /Edge\/([\d.]+)/; if ((matchIE_.exec(navigator.userAgent) != null)) { ver_ = (parseFloat(RegExp.$1)); } return ver_; } static cw(e_) { let a = BaseDOMEventProxy.cf >= 6; let oe_ = e_.originalEvent; if ((((typeof e_.pageX == 'undefined')) || a) && oe_.clientX != null) { let od_; if ((e_.target !== undefined)) { od_ = e_.target.ownerDocument; } else { od_ = e_.originalEvent.target.ownerDocument; } let ed_ = od_ ? od_ : document; let doc_ = ed_.documentElement; let body_ = ed_.body; let clientX_ = oe_.clientX; let clientY_ = oe_.clientY; let scrollLeft_ = doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0; let scrollTop_ = doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0; let clientLeft_ = doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0; let clientTop_ = doc_ && doc_.clientTop || body_ && body_.clientTop || 0; e_.pageX = clientX_ + (scrollLeft_ - clientLeft_); e_.pageY = clientY_ + (scrollTop_ - clientTop_); } if ((!e_.pageX)) { e_.pageX = e_.originalEvent.pageX; } if ((!e_.pageY)) { e_.pageY = e_.originalEvent.pageY; } if (((typeof e_.button == 'undefined')) && ((typeof oe_.button != 'undefined'))) { e_.button = oe_.button; } } static c8(a) { let b = BaseDOMEventProxy.cf >= 6; let source_ = a.getNativeElement(); let d_ = source_.ownerDocument; let doc_ = d_ ? d_.documentElement : null; let z_ = doc_ ? doc_.msContentZoomFactor : null; let body_ = doc_.body; if ((z_ && z_ > 1) || b) { let rect_ = source_.getBoundingClientRect(); let x_ = (rect_.left); let y_ = (rect_.top); let scrollLeft_ = (doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0); let scrollTop_ = (doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0); let clientLeft_ = (doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0); let clientTop_ = (doc_ && doc_.clientTop || body_ && body_.clientTop || 0); let c = x_ + scrollLeft_ - clientLeft_; let d = y_ + scrollTop_ - clientTop_; return new Rect(0, c, d, 0, 0); } else { let e = a.getOffset(); return new Rect(0, e.left, e.top, 0, 0); } } get cb() { return this.b8; } set cb(a) { this.b8 = a; } c1(a) { this.au = a; BaseDOMEventProxy.cw(a); let b = BaseDOMEventProxy.c8(this.b7); let c = 0; let d = 0; if (Rect.l_op_Inequality(this.bo, null)) { c = this.bo.left; d = this.bo.top; } this.b4 = (a.pageX - b.left) * this.ap; this.b5 = (a.pageY - b.top) * this.ap; this.b2 = this.b4 - c; this.b3 = this.b5 - d; this.c7 = { $type: Point_$type, x: this.b4, y: this.b5 }; this.c6 = { $type: Point_$type, x: this.b2, y: this.b3 }; } c2(e_) { this.au = e_; BaseDOMEventProxy.cw(e_); if (BaseDOMEventProxy.b1) { let a = e_.pageX; let b = e_.pageY; let c = BaseDOMEventProxy.c8(this.b7); this.b4 = a - c.left; this.b5 = b - c.top; } else { this.b8 = 0; if (!e_.originalEvent.targetTouches || e_.originalEvent.targetTouches.length < 1) { return; } ; this.b8 = (e_.originalEvent.targetTouches.length); let d = (e_.originalEvent.targetTouches[0].pageX); let e = (e_.originalEvent.targetTouches[0].pageY); let f = BaseDOMEventProxy.c8(this.b7); this.b4 = d - f.left; this.b5 = e - f.top; } let g = 0; let h = 0; if (Rect.l_op_Inequality(this.bo, null)) { g = this.bo.left; h = this.bo.top; } this.b2 = this.b4 - g; this.b3 = this.b5 - h; this.c7 = { $type: Point_$type, x: this.b4, y: this.b5 }; this.c6 = { $type: Point_$type, x: this.b2, y: this.b3 }; } cq(e_) { this.c0(e_); if (this.ae(this.c7, false, true)) { let deltaY_ = 0; let ev_ = e_; deltaY_ = (ev_.originalEvent ? ev_.originalEvent.deltaY : ev_.deltaY); let deltaX_ = 0; deltaX_ = (ev_.originalEvent ? ev_.originalEvent.deltaX : ev_.deltaX); let a = (ev_.originalEvent ? (ev_.originalEvent.deltaMode == 1) : (ev_.deltaMode == 1)); if (a) { deltaY_ = deltaY_ * 40; deltaX_ = deltaX_ * 40; } let b = this.ak(this.c6, deltaY_); let c = this.al(this.c6, deltaX_); if (b || c) { this.cy(e_); } } } co(e_) { this.c0(e_); this.c1(e_); if (this.ae(this.c7, false, true)) { let ev_ = e_; let delta_ = 0; if (ev_.wheelDelta) { delta_ = ev_.wheelDelta / 120; } ; if (ev_.originalEvent && ev_.originalEvent.wheelDelta) { delta_ = ev_.originalEvent.wheelDelta / 120; } ; if (ev_.detail) { delta_ = -ev_.detail / 3; } ; if (ev_.originalEvent && ev_.originalEvent.detail) { delta_ = -ev_.originalEvent.detail / 3; } ; delta_ = delta_ / 10; let a = this.ak(this.c6, delta_); if (a) { this.cy(e_); } } } cv() { if (this.bq) { if (this.b9 == -1) { this.b9 = this.b6.setTimeout(runOn(this, this.ct), 500); } else { window.clearTimeout(this.b9); this.b9 = -1; this.b9 = this.b6.setTimeout(runOn(this, this.ct), 500); } } } cg() { this.bq = true; if (this.b9 != -1) { window.clearTimeout(this.b9); this.b9 = -1; } } ct() { this.bq = false; } get bz() { return this.bs; } set bz(a) { this.bs = a; } cm(a) { if (this.bs || this.bq) { return; } this.c1(a); if (this.bv) { this.bv = false; this.bc(this.c6); } } cn(a) { if (this.bs || this.bq) { return; } this.c1(a); this.c0(a); let b = new MouseEventArgs(); b.position = this.c7; if (this.ae(this.c7, false, false)) { if (!this.bv) { this.bv = true; this.bb(this.c7); } this.bd(this.c7, true, false); this.a0(this.c6, false); } else if (this.bv) { this.cm(a); } } cz(a) { let eventSource_ = this.b7.getNativeElement(); let targetFocusable_ = ((function (ev, boundary) { var t = (ev && (ev.originalEvent ? ev.originalEvent.target : ev.target)); while (t && t.nodeType === 1 && t !== boundary) { if (!t.disabled) { var tag = t.tagName; if (tag === 'BUTTON' || tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA' || tag === 'A') return true; var ti = t.getAttribute && t.getAttribute('tabindex'); if (ti != null && parseInt(ti, 10) >= 0) return true; } t = t.parentNode; } return false; })(a, eventSource_)); if (targetFocusable_) { return; } this.b7.focus(this.by); } cl(a) { if (this.bs || this.bq) { return; } this.cz(a); this.c1(a); this.c0(a); if (this.ae(this.c7, false, false)) { this.bp = true; this.ba(this.c7); this.a1(this.c6, false); this.cy(a); } } c3(a) { if (this.bs || this.bq) { return; } if (this.bp) { this.cp(a); } } cp(a) { if (this.bs || this.bq) { return; } this.c0(a); if (PointUtil.equals(this.c7, null) || PointUtil.equals(this.c6, null)) { this.c1(a); } let b = this.ae(this.c7, false, false) || this.bp || this.bv; this.bp = false; this.be(this.c7); this.az(this.c6, false, false); if (b) { this.cy(a); } } ci(a) { this.cj(a, true); } ck(a) { this.cj(a, false); } ch(a) { this.a7(a); } c5(a) { return BaseDOMEventProxy.c4(a); } static c4(a) { let b; switch (a.which) { case 33: b = 10; break; case 34: b = 11; break; case 36: b = 13; break; case 37: b = 14; break; case 38: b = 15; break; case 39: b = 16; break; case 40: b = 17; break; case 9: b = 2; break; case 32: b = 9; break; case 13: b = 3; break; case 27: b = 8; break; case 16: b = 4; break; case 17: b = 5; break; case 18: b = 6; break; case 8: b = 1; break; case 35: b = 12; break; case 45: b = 18; break; case 46: b = 19; break; case 106: b = 78; break; case 107: b = 79; break; case 109: b = 80; break; case 110: b = 81; break; case 111: b = 82; break; case 220: b = 85; break; case 192: b = 86; break; case 191: b = 84; break; case 186: b = 83; break; case 189: b = 88; break; case 187: b = 87; break; default: if (112 <= a.which && a.which <= 123) { b = (56 + a.which - 112); } else if (65 <= a.which && a.which <= 90) { b = (30 + a.which - 65); } else if (48 <= a.which && a.which <= 57) { b = (20 + a.which - 48); } else if (96 <= a.which && a.which <= 105) { b = (68 + a.which - 96); } else { b = 0; } break; } return b; } cj(a, b) { let c = this.c5(a); let d = c != 0; this.c0(a); if (d) { let e = false; if (b) { e = this.ai(c); } else { e = this.aj(c); } if (e) { this.cy(a); } } } c0(a) { this.au = a; this.bl = 0; if (a.shiftKey) { this.bl = this.bl | 4; } if (a.altKey) { this.bl = this.bl | 1; } if (a.ctrlKey) { this.bl = this.bl | 2; } this.am = a.button == 2; } bm() { let a = BaseDOMEventProxy.c8(this.b7); let b = a.left; let c = a.top; return { $type: Point_$type, x: b, y: c }; } } BaseDOMEventProxy.$t = /*@__PURE__*/ markType(BaseDOMEventProxy, 'BaseDOMEventProxy', EventProxy.$); BaseDOMEventProxy.bw = false; BaseDOMEventProxy.bx = false; BaseDOMEventProxy.cf = 0; BaseDOMEventProxy.cc = 0; return BaseDOMEventProxy; })(); /** * @hidden */ export let DOMEventProxy = /*@__PURE__*/ (() => { class DOMEventProxy extends BaseDOMEventProxy { constructor(a, b, c) { super(); this.di = 0; this.dk = ""; this.da = false; this.dj = null; this.dc = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0); this.d7 = null; this.dg = -1; this.d8 = null; this.de = 0; this.df = 0; this.dd = 5; this.c9 = false; this.d6 = null; this.b0 = c; this.b6 = b; this.ar = (d) => true; this.ac = false; DOMEventProxy.dh++; this.di = DOMEventProxy.dh; this.dk = ".DOMProxy" + this.di.toString(); this.bl = 0; this.b7 = a; BaseDOMEventProxy.bw = false; try { BaseDOMEventProxy.bw = (window.navigator.msPointerEnabled && window.MSGesture !== undefined); } catch (d) { } BaseDOMEventProxy.bx = false; try { BaseDOMEventProxy.bx = (window.PointerEvent !== undefined); } catch (e) { } BaseDOMEventProxy.cf = this.ce(); BaseDOMEventProxy.cc = this.cd(); this.av(this.b7, ""); this.aq = (f) => true; } dl(a, b, c) { } av(a, b) { let c = a; let d = this.dk + b; if (!this.b6.supportsDOMEvents()) { return; } let e = new List$1(Delegate_$type, 0); this.dc.addItem(d, e); this.dl(a, b, e); if (!BaseDOMEventProxy.b1) { e.add(c.listen("mousemove", runOn(this, this.cn))); e.add(c.listen("mouseleave", runOn(this, this.cm))); e.add(c.listen("mousedown", runOn(this, this.cl))); e.add(c.listen("mouseup", runOn(this, this.cp))); e.add(this.b6.globalListen("window", "mouseup", runOn(this, this.c3))); } e.add(c.listen("keydown", runOn(this, this.ci))); e.add(c.listen("keyup", runOn(this, this.ck))); let source_ = this.b7.getNativeElement(); if (!this.af) { BaseDOMEventProxy.cx(source_); } if (BaseDOMEventProxy.b1) { let f = this.b7.getNativeElement(); if ((window.MSGesture !== undefined)) { let gesture_ = new window.MSGesture(); let container_ = f; gesture_.target = container_; this.dj = gesture_; e.add(c.listen("MSGestureStart", runOn(this, this.dp))); e.add(c.listen("MSGestureChange", runOn(this, this.dm))); e.add(c.listen("MSGestureEnd", runOn(this, this.dn))); } if (BaseDOMEventProxy.bx) { e.add(c.listen("pointerdown", runOn(this, this.ds))); e.add(c.listen("pointerup", runOn(this, this.dv))); e.add(c.listen("pointercancel", runOn(this, this.dr))); e.add(c.listen("pointermove", runOn(this, this.dt))); e.add(c.listen("pointerout", runOn(this, this.du))); e.add(c.listen("lostpointercapture", runOn(this, this.dq))); } else { e.add(c.listen("MSPointerDown", runOn(this, this.ds))); e.add(c.listen("MSPointerUp", runOn(this, this.dv))); e.add(c.listen("MSPointerCancel", runOn(this, this.dr))); e.add(c.listen("MSPointerMove", runOn(this, this.dt))); e.add(c.listen("MSPointerOut", runOn(this, this.du))); e.add(c.listen("MSLostPointerCapture", runOn(this, this.dq))); } } else { e.add(c.listen("gesturestart", runOn(this, this.dp))); e.add(c.listen("gesturechange", runOn(this, this.dm))); e.add(c.listen("gestureend", runOn(this, this.dn))); e.add(c.listen("touchstart", runOn(this, this.dy))); e.add(c.listen("touchmove", runOn(this, this.dx))); e.add(c.listen("touchend", runOn(this, this.dw))); } if (this.b0) { e.add(c.listen("wheel", runOn(this, this.cq))); } else { e.add(c.listen("DOMMouseScroll", runOn(this, this.co))); e.add(c.listen("mousewheel", runOn(this, this.co))); } } dv(e_) { let a = this.bu(e_); if (a) { this.cb = this.cb - 1; if (this.cb < 0) { this.cb = 0; } } if (this.cb < 2 && this.da && a) { this.da = false; let b = (e_.originalEvent.scale); this.a6(this.c6, b); } else { if (a) { this.dw(e_); } else { this.cp(e_); } } } dq(e_) { let a = this.bu(e_); if (a) { this.cb--; if (this.cb < 0) { this.cb = 0; } } if (this.cb < 2 && this.da && a) { this.da = false; let b = (e_.originalEvent.scale); this.a6(this.c6, b); } } dr(e_) { let a = this.bu(e_); if (a) { this.cb--; if (this.cb < 0) { this.cb = 0; } } if (this.cb < 2 && this.da && a) { this.da = false; let b = (e_.originalEvent.scale); this.a6(this.c6, b); } } ds(e_) { let a = this.bu(e_); if (this.dj != null && a) { this.cb++; let mGesture_ = this.dj; mGesture_.addPointer(e_.originalEvent.pointerId); } let eventSource_ = this.b7.getNativeElement(); if (BaseDOMEventProxy.bx) { eventSource_.setPointerCapture(e_.originalEvent.pointerId); } else { eventSource_.msSetPointerCapture(e_.originalEvent.pointerId); } if (this.cb > 1 && !this.da && a) { this.da = true; this.c2(e_); let b = (e_.originalEvent.scale); this.bg(this.c6, b); } else { if (a) { this.dy(e_); } else { this.cl(e_); } } } dt(e_) { let a = this.bu(e_); if (this.da) { return; } if (a) { this.dx(e_); } else { this.cn(e_); } } du(e_) { let a = this.bu(e_); if (this.da) { return; } if (a) { } else { this.cm(e_); } } dp(e_) { this.bv = true; this.c0(e_); this.c2(e_); this.d0(); if (this.ae(this.c7, true, false)) { this.cy(e_); if (BaseDOMEventProxy.b1 && this.cb < 2) { return; } let a = (e_.originalEvent.scale); this.bg(this.c6, a); } } dm(e_) { this.bv = true; this.c0(e_); this.c2(e_); if (this.ae(this.c7, true, false)) { this.cy(e_); if (BaseDOMEventProxy.b1 && this.cb < 2) { return; } let a = (e_.originalEvent.scale); this.bf(this.c6, a); } } dn(e_) { this.cy(e_); let a = (e_.originalEvent.scale); this.bv = false; this.c0(e_); this.c2(e_); if (!BaseDOMEventProxy.b1 || this.da) { this.a6(this.c6, a); } } dy(e_) { this.bv = true; this.c0(e_); this.c2(e_); this.d7 = this.c6; if (this.ae(this.c7, true, false)) { if (!this.ac) { this.cy(e_); } else { this.bz = true; } this.bd(this.c7, false, true); this.ba(this.c7); this.a1(this.c6, true); this.d3(); } } d3() { if (this.dg == -1) { this.de = this.c7.x; this.df = this.c7.y; this.dg = this.b6.setTimeout(runOn(this, this.d1), 1500); } } d0() { if (Math.abs(this.de - this.c7.x) > this.dd || Math.abs(this.df - this.c7.y) > this.dd) { this.d4(); } } d4() { if (this.dg != -1) { window.clearTimeout(this.dg); this.dg = -1; } } d1() { this.dg = -1; if (this.bz) { this.bz = false; this.cg(); } this.a8(this.c6); } dx(a) { this.bv = true; this.c0(a); this.c2(a); if (this.bz) { if (this.ae(this.c7, true, false) && this.db()) { this.bz = false; this.cg(); } } this.d0(); this.d5(); if (this.ae(this.c7, true, false) && this.cb == 1 && !this.bz) { this.cy(a); if (!this.c9) { this.c9 = true; this.d6 = this.c6; this.a5(this.d6); } else { this.bd(this.c7, true, true); this.a0(this.c6, true); this.a4(this.c6); } } } db() { let a = { $type: Point_$type, x: this.d7.x - this.c6.x, y: this.d7.y - this.c6.y }; if (Math.abs(a.x) < 2 && Math.abs(a.y) < 2) { return false; } if (Math.abs(a.x) > Math.abs(a.y)) { a.y = 0; } if (Math.abs(a.y) > Math.abs(a.x)) { a.x = 0; } return this.ar(a); } dw(a) { this.bv = false; this.c0(a); this.c2(a); this.d4(); if (this.bz) { this.bz = false; this.cg(); } this.cy(a); this.bd(this.c7, false, true); this.be(this.c7); if (this.cb == 0) { this.d2(this.c7); this.cv(); } if (this.c9 && this.cb == 0) { this.c9 = false; this.d6 = null; this.a3(this.c6); this.cv(); } this.az(this.c6, true, this.cb > 0); } d2(a) { if (Rect.l_op_Equality(this.d8, null)) { this.d8 = new Rect(0, a.x - 50, a.y - 50, 100, 100); this.b6.setTimeout(runOn(this, this.d5), 500); } else { if (a.x >= this.d8.x && a.x <= this.d8.right && a.y >= this.d8.y && a.y <= this.d8.bottom) { this.d5(); this.a2(a); } } } d5() { this.d8 = null; } dz(a) { if (this.dc.containsKey(a)) { let b = this.dc.item(a); this.dc.removeItem(a); for (let c = 0; c < b.count; c++) { b._inner[c](); } b.clear(); } } bk(a, b) { if (a == null) { return; } let c = a; let d = this.dk + b; this.dz(d); } ax() { if (this.b7 == null) { return; } this.dz(this.dk); this.b7 = null; } } DOMEventProxy.$t = /*@__PURE__*/ markType(DOMEventProxy, 'DOMEventProxy', BaseDOMEventProxy.$); DOMEventProxy.dh = 0; return DOMEventProxy; })();