UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

545 lines (544 loc) 17.2 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 { __extends } from "tslib"; 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 */ var EditorCell = /** @class */ /*@__PURE__*/ (function (_super) { __extends(EditorCell, _super); function EditorCell(a) { var _this = _super.call(this, a) || this; _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)); return _this; } Object.defineProperty(EditorCell.prototype, "cn", { get: function () { return this.cm; }, set: function (a) { var b = this.cm; this.cm = a; if (b != this.cm) { this.bs("DataType", enumGetBox(DataSourceSchemaPropertyType_$type, b), enumGetBox(DataSourceSchemaPropertyType_$type, this.cm)); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "dl", { get: function () { return this.dj; }, set: function (a) { var b = this.dj; this.dj = a; this.bs("Value", b, this.dj); }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "c2", { get: function () { return this.c1; }, set: function (a) { var b = this.c1; this.c1 = a; if (b != this.c1) { this.bs("FontInfo", b, this.c1); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "cr", { get: function () { return this.cq; }, set: function (a) { var b = this.cq; this.cq = a; if (b != this.cq) { this.bs("EditorType", enumGetBox(EditorType_$type, b), enumGetBox(EditorType_$type, this.cq)); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "dk", { get: function () { return this.di; }, set: function (a) { var b = this.di; this.di = a; if (b != this.di) { this.bs("ComboItemsSource", b, this.di); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "dq", { get: function () { return this.dm; }, set: function (a) { var b = this.dm; this.dm = a; if (b != this.dm) { this.bs("ComboTextField", b, this.dm); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "cl", { get: function () { return this.ck; }, set: function (a) { var b = this.ck; this.ck = a; if (b != this.ck) { this.bs("ComboValueField", b, this.ck); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "dd", { get: function () { return this.c5; }, set: function (a) { var b = this.c5; this.c5 = a; if (b != this.c5) { this.bs("IsHidden", b, this.c5); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "du", { get: function () { return this.dn; }, set: function (a) { var b = this.dn; this.dn = a; if (b != this.dn) { this.bs("DateFormatString", b, this.dn); } }, enumerable: false, configurable: true }); Object.defineProperty(EditorCell.prototype, "de", { get: function () { return this.c6; }, set: function (a) { var b = this.c6; this.c6 = a; if (b != this.c6) { this.bs("ShowTodayButton", b, this.c6); } }, enumerable: false, configurable: true }); EditorCell.prototype.cx = function (a) { if (this.df == null) { this.df = this.ae.createElement("div"); var 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); } var 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; }; EditorCell.prototype.cw = function () { 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; }; EditorCell.prototype.cv = function () { 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; }; EditorCell.prototype.cu = function () { 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; }; EditorCell.prototype.ct = function () { 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; }; EditorCell.prototype.ed = function (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(); } }; EditorCell.prototype.d1 = function () { if (!this.c4) { if (this.cs != null) { this.cs.attachEvents(); var a = this.cs; a.valueProvided = delegateCombine(a.valueProvided, runOn(this, this.ej)); var b = this.cs; b.lostFocus = delegateCombine(b.lostFocus, runOn(this, this.d9)); var c = this.cs; c.gotFocus = delegateCombine(c.gotFocus, runOn(this, this.d8)); var d = this.cs; d.userTyping = delegateCombine(d.userTyping, runOn(this, this.eh)); this.c4 = true; } } }; EditorCell.prototype.d2 = function () { if (this.c4) { if (this.cs != null) { this.cs.detachEvents(); var a = this.cs; a.valueProvided = delegateRemove(a.valueProvided, runOn(this, this.ej)); var b = this.cs; b.lostFocus = delegateRemove(b.lostFocus, runOn(this, this.d9)); var c = this.cs; c.gotFocus = delegateRemove(c.gotFocus, runOn(this, this.d8)); var d = this.cs; d.userTyping = delegateRemove(d.userTyping, runOn(this, this.eh)); this.c4 = false; } } }; EditorCell.prototype.eg = function (a) { this.c9 = false; this.da = false; this.c8 = false; if (!a) { this.da = true; this.cs.onTargetChanged(); } }; EditorCell.prototype.ei = function () { if (this.cs != null) { this.cs.value = this.dl; } }; EditorCell.prototype.d6 = function () { }; EditorCell.prototype.ea = function () { 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; }; EditorCell.prototype.d5 = function () { if (this.co != null) { this.co.ah = this.dk; this.co.ak = this.dq; this.co.aa = this.cl; } }; EditorCell.prototype.eb = function () { 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); } }; EditorCell.prototype.d4 = function () { 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; } } }; EditorCell.prototype.d7 = function () { if (this.cs != null && this.cp == this.cs) { this.cp.af = this.du; } }; EditorCell.prototype.ef = function () { if (this.cs != null && this.cp == this.cs) { this.cp.ad = this.de; } }; EditorCell.prototype.ek = function (a, b, c, d, e) { if (!stringIsNullOrWhiteSpace(a)) { this.dg.setRawText(a); this.c0.b9(); this.el(); } }; EditorCell.prototype.el = function () { var rect_ = this.ah.getNativeElement().getBoundingClientRect(); var 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); }; EditorCell.prototype.d3 = function () { if (this.c0.ax) { this.c0.b6(); } }; EditorCell.prototype.br = function () { if (this.cs == null) { this.ea(); this.f.setViewportChangedHandler(runOn(this, this.ed)); } }; EditorCell.prototype.bh = function () { if (this.cs != null) { this.cs.focus(); } }; EditorCell.prototype.bs = function (a, b, c) { _super.prototype.bs.call(this, 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; } }; EditorCell.prototype.ej = function (a, b, c) { if (a == this.cs) { if (!c) { this.b.updateCellEditValue(b); } } }; EditorCell.prototype.eh = function (a) { if (a == this.cs) { this.b.startEditMode(); } }; EditorCell.prototype.dc = function (a) { if (a != null && this.c0 != null && this.c0.ax) { var b = this.dh.getNativeElement(); return b.contains(a); } return false; }; EditorCell.prototype.db = function (a) { if (a != null) { var b = this.ah.getNativeElement(); return b.contains(a); } return false; }; EditorCell.prototype.ee = function (a) { var _this = this; if (!this.c3) { var b = (a.originalEvent.relatedTarget); if (this.c8 && !this.db(b) && !this.dc(b)) { this.b.editorCellLostFocus(); this.d3(); } var c = this.ae.rootWrapper.getNativeElement(); if (c.contains(b)) { window.setTimeout(function () { var 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); } } }; EditorCell.prototype.ec = function (a) { if (this.c9 && !this.c0.ax) { this.el(); } }; EditorCell.prototype.d9 = function (a) { this.c8 = true; }; EditorCell.prototype.d8 = function (a) { this.c8 = false; }; EditorCell.prototype.onContactStarted = function (a, b) { a.stopPropagation(); }; EditorCell.prototype.onContactCompleted = function (a, b) { a.stopPropagation(); }; EditorCell.prototype.onDoubleClick = function (a) { a.stopPropagation(); }; EditorCell.$t = markType(EditorCell, 'EditorCell', GridCellBase.$); return EditorCell; }(GridCellBase)); export { EditorCell };