UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

261 lines (260 loc) 9.27 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 { 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 */ export let ComboEditorView = /*@__PURE__*/ (() => { class ComboEditorView extends BaseEditorView { get ah() { return this.ag; } set ah(a) { let b = this.ag; this.ag = a; if (b != this.ag) { this.v("DataSource", b, this.ag); } } get ak() { return this.ai; } set ak(a) { let b = this.ai; this.ai = a; if (b != this.ai) { this.v("TextField", b, this.ai); } } get aa() { return this.z; } set aa(a) { let b = this.z; this.z = a; if (b != this.z) { this.v("ValueField", b, this.z); } } constructor(a, b, c) { super(a, c); this.ac = null; this.ab = null; this.af = null; this.ad = false; this.ag = null; this.ai = null; this.z = null; this.ae = false; let d = a.createElement("div"); d.setRawStyleProperty("margin-top", "-10px"); d.setRawStyleProperty("height", "38px"); d.setRawStyleProperty("width", "100%"); this.container = d; a.getPortal(d, "MultiColumnComboBox", (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(() => this.ab.select(), 0); this.ad = false; } }, false); } setFont(a) { this.ac = a; if (this.ab != null && this.ac != null) { this.ab.textStyle = this.ac.fontString; } } attachEvents() { if (this.ab != null) { let a = this.ab; a.selectedValueChanged = delegateCombine(a.selectedValueChanged, runOn(this, this.onComboValueChanged)); let b = this.ab; b.textValueChanged = delegateCombine(b.textValueChanged, runOn(this, this.onComboTextChanged)); let c = this.ab; c.gotFocus = delegateCombine(c.gotFocus, runOn(this, this.onComboGotFocus)); let d = this.ab; d.lostFocus = delegateCombine(d.lostFocus, runOn(this, this.onComboLostFocus)); let e = this.ab; e.keyDown = delegateCombine(e.keyDown, runOn(this, this.onInputKeyDown)); let f = this.ab; f.changing = delegateCombine(f.changing, runOn(this, this.onInputChanging)); } } detachEvents() { if (this.ab != null) { let a = this.ab; a.selectedValueChanged = delegateRemove(a.selectedValueChanged, runOn(this, this.onComboValueChanged)); let b = this.ab; b.textValueChanged = delegateRemove(b.textValueChanged, runOn(this, this.onComboTextChanged)); let c = this.ab; c.gotFocus = delegateRemove(c.gotFocus, runOn(this, this.onComboGotFocus)); let d = this.ab; d.lostFocus = delegateRemove(d.lostFocus, runOn(this, this.onComboLostFocus)); let e = this.ab; e.keyDown = delegateRemove(e.keyDown, runOn(this, this.onInputKeyDown)); let f = this.ab; f.changing = delegateRemove(f.changing, runOn(this, this.onInputChanging)); } } onTargetChanged() { if (this.ab != null) { this.ae = true; if (this.ab.value == null && this.ab.text != "") { this.ab.text = ""; } this.focus(); this.ae = false; } } onEditStarted() { if (this.ab != null) { super.onEditStarted(); let a = this.container.getNativeElement(); this.ab.defaultColumnWidth = (a.clientWidth - 2).toString(); if (!this.a.isEditRefocusDesired) { this.focus(); } } else { this.ad = true; } } onEditEnded() { super.onEditEnded(); if (this.a.isEditRefocusDesired) { let a = this.i.rootWrapper.getNativeElement(); if (a == document.activeElement || a.contains(document.activeElement)) { this.focus(); } } this.ad = false; } t() { if (this.ab != null) { this.af.focus(true); this.ab.select(); } } an() { if (this.ab != null) { this.ab.closeUp(); } } v(a, b, c) { super.v(a, b, c); switch (a) { case "DataSource": case "TextField": case "ValueField": this.aq(); break; } } x() { 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; } aq() { 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 { let a = typeCast(IDataSource_$type, this.ah); if (a != null && a.actualSchema != null) { this.ab.fields = [a.actualSchema.propertyNames[0]]; } else { let b = (Array.isArray(this.ah)); if (b) { let c = (this.ah.length); if (c > 0) { let d = (Object.keys(this.ah[0])); if (d.length > 0) { this.ab.fields = [d[0]]; } } } } } this.attachEvents(); } } w() { super.w(); if (this.ab != null) { this.ab.textColor = this.textColor._fill; } } onComboValueChanged(a, b) { this.au(); } onComboTextChanged(a, b) { this.au(); } au() { 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); } } onInputChanging(a, b) { this.q(); } onComboLostFocus(a) { this.p(); } onComboGotFocus(a) { this.o(); } } ComboEditorView.$t = /*@__PURE__*/ markType(ComboEditorView, 'ComboEditorView', BaseEditorView.$); return ComboEditorView; })();