UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

275 lines (274 loc) 9.81 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 { BaseEditorView } from "./BaseEditorView"; import { runOn, delegateCombine, delegateRemove, typeCast, markType } from "igniteui-react-core"; import { IDataSource_$type } from "igniteui-react-core"; import { stringIsNullOrWhiteSpace } from "igniteui-react-core"; /** * @hidden */ var ComboEditorView = /** @class */ /*@__PURE__*/ (function (_super) { __extends(ComboEditorView, _super); function ComboEditorView(a, b, c) { var _this = _super.call(this, a, c) || this; _this.ac = null; _this.ab = null; _this.af = null; _this.ad = false; _this.ag = null; _this.ai = null; _this.z = null; _this.ae = false; var d = a.createElement("div"); d.setRawStyleProperty("margin-top", "-10px"); d.setRawStyleProperty("height", "38px"); d.setRawStyleProperty("width", "100%"); _this.container = d; a.getPortal(d, "MultiColumnComboBox", function (e) { _this.ab = e.componentRef; _this.af = _this.ab.i; _this.ab.height = "100%"; _this.ab.density = 3; _this.ab.baseTheme = b; _this.ab.labelVisible = false; _this.ab.columnHeadersVisible = false; _this.ab.rowSeparatorsVisible = false; _this.af.disallowTabFocus = true; _this.aq(); _this.x(); if (_this.ac != null) { _this.ab.textStyle = _this.ac.fontString; } _this.attachEvents(); if (_this.ad) { _this.onEditStarted(); window.setTimeout(function () { return _this.ab.select(); }, 0); _this.ad = false; } }, false); return _this; } Object.defineProperty(ComboEditorView.prototype, "ah", { get: function () { return this.ag; }, set: function (a) { var b = this.ag; this.ag = a; if (b != this.ag) { this.v("DataSource", b, this.ag); } }, enumerable: false, configurable: true }); Object.defineProperty(ComboEditorView.prototype, "ak", { get: function () { return this.ai; }, set: function (a) { var b = this.ai; this.ai = a; if (b != this.ai) { this.v("TextField", b, this.ai); } }, enumerable: false, configurable: true }); Object.defineProperty(ComboEditorView.prototype, "aa", { get: function () { return this.z; }, set: function (a) { var b = this.z; this.z = a; if (b != this.z) { this.v("ValueField", b, this.z); } }, enumerable: false, configurable: true }); ComboEditorView.prototype.setFont = function (a) { this.ac = a; if (this.ab != null && this.ac != null) { this.ab.textStyle = this.ac.fontString; } }; ComboEditorView.prototype.attachEvents = function () { if (this.ab != null) { var a = this.ab; a.selectedValueChanged = delegateCombine(a.selectedValueChanged, runOn(this, this.onComboValueChanged)); var b = this.ab; b.textValueChanged = delegateCombine(b.textValueChanged, runOn(this, this.onComboTextChanged)); var c = this.ab; c.gotFocus = delegateCombine(c.gotFocus, runOn(this, this.onComboGotFocus)); var d = this.ab; d.lostFocus = delegateCombine(d.lostFocus, runOn(this, this.onComboLostFocus)); var e = this.ab; e.keyDown = delegateCombine(e.keyDown, runOn(this, this.onInputKeyDown)); var f = this.ab; f.changing = delegateCombine(f.changing, runOn(this, this.onInputChanging)); } }; ComboEditorView.prototype.detachEvents = function () { if (this.ab != null) { var a = this.ab; a.selectedValueChanged = delegateRemove(a.selectedValueChanged, runOn(this, this.onComboValueChanged)); var b = this.ab; b.textValueChanged = delegateRemove(b.textValueChanged, runOn(this, this.onComboTextChanged)); var c = this.ab; c.gotFocus = delegateRemove(c.gotFocus, runOn(this, this.onComboGotFocus)); var d = this.ab; d.lostFocus = delegateRemove(d.lostFocus, runOn(this, this.onComboLostFocus)); var e = this.ab; e.keyDown = delegateRemove(e.keyDown, runOn(this, this.onInputKeyDown)); var f = this.ab; f.changing = delegateRemove(f.changing, runOn(this, this.onInputChanging)); } }; ComboEditorView.prototype.onTargetChanged = function () { if (this.ab != null) { this.ae = true; if (this.ab.value == null && this.ab.text != "") { this.ab.text = ""; } this.focus(); this.ae = false; } }; ComboEditorView.prototype.onEditStarted = function () { if (this.ab != null) { _super.prototype.onEditStarted.call(this); var a = this.container.getNativeElement(); this.ab.defaultColumnWidth = (a.clientWidth - 2).toString(); if (!this.a.isEditRefocusDesired) { this.focus(); } } else { this.ad = true; } }; ComboEditorView.prototype.onEditEnded = function () { _super.prototype.onEditEnded.call(this); if (this.a.isEditRefocusDesired) { var a = this.i.rootWrapper.getNativeElement(); if (a == document.activeElement || a.contains(document.activeElement)) { this.focus(); } } this.ad = false; }; ComboEditorView.prototype.t = function () { if (this.ab != null) { this.af.focus(true); this.ab.select(); } }; ComboEditorView.prototype.an = function () { if (this.ab != null) { this.ab.closeUp(); } }; ComboEditorView.prototype.v = function (a, b, c) { _super.prototype.v.call(this, a, b, c); switch (a) { case "DataSource": case "TextField": case "ValueField": this.aq(); break; } }; ComboEditorView.prototype.x = function () { this.ae = true; if (this.ab != null) { if (this.value == null) { this.ab.text = " "; } this.ab.value = this.value; if (this.focusOnValueChanged && !this.h()) { this.t(); } } this.ae = false; }; ComboEditorView.prototype.aq = function () { if (this.ab != null) { this.detachEvents(); this.ab.dataSource = this.ah; this.ab.textField = this.ak; this.ab.valueField = this.aa; if (this.ak != null) { this.ab.fields = [this.ak]; } else if (this.aa != null && this.aa.length > 0) { this.ab.fields = [this.aa[0]]; } else { var a = typeCast(IDataSource_$type, this.ah); if (a != null && a.actualSchema != null) { this.ab.fields = [a.actualSchema.propertyNames[0]]; } else { var b = (Array.isArray(this.ah)); if (b) { var c = (this.ah.length); if (c > 0) { var d = (Object.keys(this.ah[0])); if (d.length > 0) { this.ab.fields = [d[0]]; } } } } } this.attachEvents(); } }; ComboEditorView.prototype.w = function () { _super.prototype.w.call(this); if (this.ab != null) { this.ab.textColor = this.textColor._fill; } }; ComboEditorView.prototype.onComboValueChanged = function (a, b) { this.au(); }; ComboEditorView.prototype.onComboTextChanged = function (a, b) { this.au(); }; ComboEditorView.prototype.au = function () { if (this.ae) { return; } if (this.ab.value != null) { this.r(this.ab.value, false); } else if (this.ab.value == null && stringIsNullOrWhiteSpace(this.ab.text)) { this.r(null, false); } else { this.r(this.value, false); } }; ComboEditorView.prototype.onInputChanging = function (a, b) { this.q(); }; ComboEditorView.prototype.onComboLostFocus = function (a) { this.p(); }; ComboEditorView.prototype.onComboGotFocus = function (a) { this.o(); }; ComboEditorView.$t = markType(ComboEditorView, 'ComboEditorView', BaseEditorView.$); return ComboEditorView; }(BaseEditorView)); export { ComboEditorView };