UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

502 lines (501 loc) 16 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 { GridCellBase } from "./GridCellBase"; import { DataSourceSchemaPropertyType_$type } from "igniteui-react-core"; import { enumGetBox, runOn, delegateCombine, delegateRemove, markType } from "igniteui-react-core"; import { EditorType_$type } from "./EditorType"; import { Popup } from "igniteui-react-core"; import { TextEditorView } from "./TextEditorView"; import { NumericEditorView } from "./NumericEditorView"; import { DateEditorView } from "./DateEditorView"; import { ComboEditorView } from "./ComboEditorView"; import { Rect } from "igniteui-react-core"; import { stringIsNullOrWhiteSpace } from "igniteui-react-core"; /** * @hidden */ export let EditorCell = /*@__PURE__*/ (() => { class EditorCell extends GridCellBase { get cn() { return this.cm; } set cn(a) { let b = this.cm; this.cm = a; if (b != this.cm) { this.bs("DataType", enumGetBox(DataSourceSchemaPropertyType_$type, b), enumGetBox(DataSourceSchemaPropertyType_$type, this.cm)); } } get dl() { return this.dj; } set dl(a) { let b = this.dj; this.dj = a; this.bs("Value", b, this.dj); } get c2() { return this.c1; } set c2(a) { let b = this.c1; this.c1 = a; if (b != this.c1) { this.bs("FontInfo", b, this.c1); } } get cr() { return this.cq; } set cr(a) { let b = this.cq; this.cq = a; if (b != this.cq) { this.bs("EditorType", enumGetBox(EditorType_$type, b), enumGetBox(EditorType_$type, this.cq)); } } get dk() { return this.di; } set dk(a) { let b = this.di; this.di = a; if (b != this.di) { this.bs("ComboItemsSource", b, this.di); } } get dq() { return this.dm; } set dq(a) { let b = this.dm; this.dm = a; if (b != this.dm) { this.bs("ComboTextField", b, this.dm); } } get cl() { return this.ck; } set cl(a) { let b = this.ck; this.ck = a; if (b != this.ck) { this.bs("ComboValueField", b, this.ck); } } get dd() { return this.c5; } set dd(a) { let b = this.c5; this.c5 = a; if (b != this.c5) { this.bs("IsHidden", b, this.c5); } } get du() { return this.dn; } set du(a) { let b = this.dn; this.dn = a; if (b != this.dn) { this.bs("DateFormatString", b, this.dn); } } get de() { return this.c6; } set de(a) { let b = this.c6; this.c6 = a; if (b != this.c6) { this.bs("ShowTodayButton", b, this.c6); } } constructor(a) { super(a); this.cs = null; this.cz = null; this.cy = null; this.cp = null; this.co = null; this.df = null; this.dg = null; this.dh = null; this.c0 = null; this.c3 = false; this.c7 = false; this.c4 = false; this.cm = 0; this.dj = null; this.c1 = null; this.cq = 1; this.di = null; this.dm = null; this.ck = null; this.c5 = true; this.dn = null; this.c6 = false; this.c9 = false; this.da = false; this.c8 = false; this.ah.setAttribute("tabindex", "-1"); this.ah.setStyleProperty("outline", "none"); this.ah.setStyleProperty("display", "flex"); this.ah.setStyleProperty("align-items", "center"); this.ah.listen("focusout", runOn(this, this.ee)); this.ah.listen("focusin", runOn(this, this.ec)); } cx(a) { if (this.df == null) { this.df = this.ae.createElement("div"); let b = this.ae.getSubRenderer(this.df); this.c0 = new Popup(); this.c0.provideRenderer(b); this.dh = this.ae.createElement("div"); this.dh.setStyleProperty("background-color", "rgba(0,0,0,0.7)"); this.dh.setStyleProperty("color", "#fff"); this.dh.setStyleProperty("padding", "5px"); this.dh.setStyleProperty("outline", "none"); this.dh.setAttribute("tabindex", "-1"); this.dg = this.ae.createElement("div"); this.dg.setStyleProperty("white-space", "pre"); if (this.c2 != null) { this.dg.setStyleProperty("font", this.c2.fontString); } this.dh.append(this.dg); this.c0.appendPopupContent(this.dh); } let c = null; switch (a) { case 1: c = this.cw(); break; case 2: c = this.cv(); break; case 3: c = this.cu(); break; case 4: c = this.ct(); break; } return c; } cw() { if (this.cz != null) { this.d6(); this.eb(); return this.cz; } this.cz = new TextEditorView(this.ae, this.f.getTheme(), this.b); this.cz.setFont(this.c2); return this.cz; } cv() { if (this.cy != null) { this.d6(); this.eb(); return this.cy; } this.cy = new NumericEditorView(this.ae, this.f.getTheme(), this.b); this.cy.setFont(this.c2); return this.cy; } cu() { if (this.cp != null) { this.d6(); this.eb(); return this.cp; } this.cp = new DateEditorView(this.ae, this.f.getTheme(), this.b); this.cp.setFont(this.c2); return this.cp; } ct() { if (this.co != null) { this.d5(); this.d6(); this.eb(); return this.co; } this.co = new ComboEditorView(this.ae, this.f.getTheme(), this.b); this.co.setFont(this.c2); this.co.ah = this.dk; this.co.ak = this.dq; this.co.aa = this.cl; return this.co; } ed(a, b) { if (b.g != b.d || b.h != b.e) { if (this.co != null) { this.co.an(); } if (this.cp != null) { this.cp.ah(); } this.d3(); } } d1() { if (!this.c4) { if (this.cs != null) { this.cs.attachEvents(); let a = this.cs; a.valueProvided = delegateCombine(a.valueProvided, runOn(this, this.ej)); let b = this.cs; b.lostFocus = delegateCombine(b.lostFocus, runOn(this, this.d9)); let c = this.cs; c.gotFocus = delegateCombine(c.gotFocus, runOn(this, this.d8)); let d = this.cs; d.userTyping = delegateCombine(d.userTyping, runOn(this, this.eh)); this.c4 = true; } } } d2() { if (this.c4) { if (this.cs != null) { this.cs.detachEvents(); let a = this.cs; a.valueProvided = delegateRemove(a.valueProvided, runOn(this, this.ej)); let b = this.cs; b.lostFocus = delegateRemove(b.lostFocus, runOn(this, this.d9)); let c = this.cs; c.gotFocus = delegateRemove(c.gotFocus, runOn(this, this.d8)); let d = this.cs; d.userTyping = delegateRemove(d.userTyping, runOn(this, this.eh)); this.c4 = false; } } } eg(a) { this.c9 = false; this.da = false; this.c8 = false; if (!a) { this.da = true; this.cs.onTargetChanged(); } } ei() { if (this.cs != null) { this.cs.value = this.dl; } } d6() { } ea() { this.c3 = true; this.d2(); this.ah.removeChildren(); if (this.cs != null) { this.cs.cleanUp(); } this.cs = this.cx(this.cr); this.ah.append(this.cs.container); this.d1(); if (this.cs != null) { this.cs.isEnabled = !this.isRemoved; if (!this.dd) { this.cs.onEditStarted(); } } this.c3 = false; } d5() { if (this.co != null) { this.co.ah = this.dk; this.co.ak = this.dq; this.co.aa = this.cl; } } eb() { if (this.c2 != null) { if (this.cz != null) { this.cz.setFont(this.c2); } if (this.cy != null) { this.cy.setFont(this.c2); } if (this.cp != null) { this.cp.setFont(this.c2); } if (this.co != null) { this.co.setFont(this.c2); } this.dg.setStyleProperty("font", this.c2.fontString); } } d4() { this.c7 = false; if (this.cs != null) { if (!this.dd) { this.cs.onEditStarted(); } else { this.cs.onEditEnded(); this.cs.value = null; this.cs.value = this.dl; } } } d7() { if (this.cs != null && this.cp == this.cs) { this.cp.af = this.du; } } ef() { if (this.cs != null && this.cp == this.cs) { this.cp.ad = this.de; } } ek(a, b, c, d, e) { if (!stringIsNullOrWhiteSpace(a)) { this.dg.setRawText(a); this.c0.b9(); this.el(); } } el() { let rect_ = this.ah.getNativeElement().getBoundingClientRect(); let a = new Rect(4); a.left = (rect_.left + window.pageXOffset); a.top = (rect_.top + window.pageYOffset); a.right = (rect_.right + window.pageXOffset); a.bottom = (rect_.bottom + window.pageYOffset); this.c0.showRelativeToExclusionRect(a, 1, 0); } d3() { if (this.c0.ax) { this.c0.b6(); } } br() { if (this.cs == null) { this.ea(); this.f.setViewportChangedHandler(runOn(this, this.ed)); } } bh() { if (this.cs != null) { this.cs.focus(); } } bs(a, b, c) { super.bs(a, b, c); switch (a) { case "EditorType": this.ea(); break; case "ComboItemsSource": case "ComboTextField": case "ComboValueField": this.d5(); break; case "DataType": this.d6(); break; case "Value": this.ei(); break; case "FontInfo": this.eb(); break; case "IsHidden": this.d4(); break; case "DateFormatString": this.d7(); break; case "ShowTodayButton": this.ef(); break; case "IsRemoved": if (this.cs != null) { this.cs.isEnabled = !this.isRemoved; if (!this.isRemoved) { this.cs.onTargetChanged(); } } break; } } ej(a, b, c) { if (a == this.cs) { if (!c) { this.b.updateCellEditValue(b); } } } eh(a) { if (a == this.cs) { this.b.startEditMode(); } } dc(a) { if (a != null && this.c0 != null && this.c0.ax) { let b = this.dh.getNativeElement(); return b.contains(a); } return false; } db(a) { if (a != null) { let b = this.ah.getNativeElement(); return b.contains(a); } return false; } ee(a) { if (!this.c3) { let b = (a.originalEvent.relatedTarget); if (this.c8 && !this.db(b) && !this.dc(b)) { this.b.editorCellLostFocus(); this.d3(); } let c = this.ae.rootWrapper.getNativeElement(); if (c.contains(b)) { window.setTimeout(() => { let d = document.activeElement.nodeName; if (d == "INPUT" || d == "SELECT" || d == "TEXTAREA" || d == "BUTTON" || d == "OPTION") { return; } if (this.b.isEditRefocusDesired && this.cs != null) { this.cs.focus(); } }, 0); } } } ec(a) { if (this.c9 && !this.c0.ax) { this.el(); } } d9(a) { this.c8 = true; } d8(a) { this.c8 = false; } onContactStarted(a, b) { a.stopPropagation(); } onContactCompleted(a, b) { a.stopPropagation(); } onDoubleClick(a) { a.stopPropagation(); } } EditorCell.$t = /*@__PURE__*/ markType(EditorCell, 'EditorCell', GridCellBase.$); return EditorCell; })();